@account-kit/wallet-client 0.1.0-alpha.7 → 0.1.0-alpha.9

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.
Files changed (91) hide show
  1. package/dist/esm/capabilities/index.d.ts +3 -0
  2. package/dist/esm/capabilities/index.js +2 -0
  3. package/dist/esm/capabilities/index.js.map +1 -1
  4. package/dist/esm/capabilities/multiDimensionalNonce.d.ts +3 -0
  5. package/dist/esm/capabilities/multiDimensionalNonce.js +7 -0
  6. package/dist/esm/capabilities/multiDimensionalNonce.js.map +1 -0
  7. package/dist/esm/client/actions/prepareCalls.d.ts +1 -1
  8. package/dist/esm/client/actions/prepareCalls.js +1 -1
  9. package/dist/esm/client/actions/prepareCalls.js.map +1 -1
  10. package/dist/esm/client/actions/signPreparedCalls.js +26 -37
  11. package/dist/esm/client/actions/signPreparedCalls.js.map +1 -1
  12. package/dist/esm/client/actions/signSignatureRequest.d.ts +3 -2
  13. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  14. package/dist/esm/exports/internal.d.ts +1 -0
  15. package/dist/esm/exports/internal.js +1 -0
  16. package/dist/esm/exports/internal.js.map +1 -1
  17. package/dist/esm/isomorphic/actions/createSession.js +20 -5
  18. package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
  19. package/dist/esm/isomorphic/actions/prepareCalls.js +39 -17
  20. package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
  21. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +62 -8
  22. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
  23. package/dist/esm/isomorphic/client.d.ts +9 -0
  24. package/dist/esm/isomorphic/utils/7702.d.ts +6 -1
  25. package/dist/esm/isomorphic/utils/7702.js +26 -12
  26. package/dist/esm/isomorphic/utils/7702.js.map +1 -1
  27. package/dist/esm/isomorphic/utils/createAccount.d.ts +1 -0
  28. package/dist/esm/isomorphic/utils/createAccount.js +96 -34
  29. package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
  30. package/dist/esm/isomorphic/utils/supportsFeature.d.ts +4 -0
  31. package/dist/esm/isomorphic/utils/supportsFeature.js +21 -0
  32. package/dist/esm/isomorphic/utils/supportsFeature.js.map +1 -0
  33. package/dist/esm/rpc/request.d.ts +54 -0
  34. package/dist/esm/rpc/request.js +1 -0
  35. package/dist/esm/rpc/request.js.map +1 -1
  36. package/dist/esm/rpc/schema.d.ts +54 -0
  37. package/dist/esm/schemas.d.ts +35 -1
  38. package/dist/esm/schemas.js +56 -1
  39. package/dist/esm/schemas.js.map +1 -1
  40. package/dist/esm/types.d.ts +3 -0
  41. package/dist/esm/types.js.map +1 -1
  42. package/dist/esm/utils.d.ts +1 -0
  43. package/dist/esm/utils.js.map +1 -1
  44. package/dist/types/capabilities/index.d.ts +3 -0
  45. package/dist/types/capabilities/index.d.ts.map +1 -1
  46. package/dist/types/capabilities/multiDimensionalNonce.d.ts +4 -0
  47. package/dist/types/capabilities/multiDimensionalNonce.d.ts.map +1 -0
  48. package/dist/types/client/actions/prepareCalls.d.ts +1 -1
  49. package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -1
  50. package/dist/types/client/actions/signSignatureRequest.d.ts +3 -2
  51. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  52. package/dist/types/exports/internal.d.ts +1 -0
  53. package/dist/types/exports/internal.d.ts.map +1 -1
  54. package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
  55. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
  56. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
  57. package/dist/types/isomorphic/client.d.ts +9 -0
  58. package/dist/types/isomorphic/client.d.ts.map +1 -1
  59. package/dist/types/isomorphic/utils/7702.d.ts +6 -1
  60. package/dist/types/isomorphic/utils/7702.d.ts.map +1 -1
  61. package/dist/types/isomorphic/utils/createAccount.d.ts +1 -0
  62. package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
  63. package/dist/types/isomorphic/utils/supportsFeature.d.ts +5 -0
  64. package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +1 -0
  65. package/dist/types/rpc/request.d.ts +54 -0
  66. package/dist/types/rpc/request.d.ts.map +1 -1
  67. package/dist/types/rpc/schema.d.ts +54 -0
  68. package/dist/types/rpc/schema.d.ts.map +1 -1
  69. package/dist/types/schemas.d.ts +35 -1
  70. package/dist/types/schemas.d.ts.map +1 -1
  71. package/dist/types/types.d.ts +3 -0
  72. package/dist/types/types.d.ts.map +1 -1
  73. package/dist/types/utils.d.ts +1 -0
  74. package/dist/types/utils.d.ts.map +1 -1
  75. package/package.json +5 -5
  76. package/src/capabilities/index.ts +2 -0
  77. package/src/capabilities/multiDimensionalNonce.ts +7 -0
  78. package/src/client/actions/prepareCalls.ts +1 -1
  79. package/src/client/actions/signPreparedCalls.ts +42 -43
  80. package/src/client/actions/signSignatureRequest.ts +4 -2
  81. package/src/exports/internal.ts +1 -0
  82. package/src/isomorphic/actions/createSession.ts +25 -4
  83. package/src/isomorphic/actions/prepareCalls.ts +48 -21
  84. package/src/isomorphic/actions/sendPreparedCalls.ts +69 -9
  85. package/src/isomorphic/utils/7702.ts +41 -14
  86. package/src/isomorphic/utils/createAccount.ts +115 -35
  87. package/src/isomorphic/utils/supportsFeature.ts +34 -0
  88. package/src/rpc/request.ts +1 -0
  89. package/src/schemas.ts +94 -3
  90. package/src/types.ts +4 -0
  91. package/src/utils.ts +2 -0
@@ -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,CA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C,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 { decodePermissionsContext } from \"../../capabilities/permissions/mav2.js\";\nimport { type wallet_sendPreparedCalls } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { TypeCallId } from \"../../schemas.js\";\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 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 return client\n .sendRawUserOperation(\n {\n ...userOp.data,\n signature:\n deferredAction != null\n ? concatHex([\n `0x${deferredAction.slice(68)}`, // Cuts off stuff prepended to the digest (nonce, etc. that we had previously).\n \"0xff\",\n \"0x00\",\n uoSigHex,\n ])\n : concat([\"0xFF\", \"0x00\", uoSigHex]),\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,cAAc,EACd,KAAK,GAKN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAiC,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,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,GAA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ountClient,\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 { decodePermissionsContext } from \"../../capabilities/permissions/mav2.js\";\nimport { type wallet_sendPreparedCalls } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { TypeCallId } from \"../../schemas.js\";\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"]}
@@ -50,11 +50,13 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
50
50
  [x: string]: unknown;
51
51
  };
52
52
  };
53
+ rawPayload: `0x${string}`;
53
54
  } | {
54
55
  type: "personal_sign";
55
56
  data: string | {
56
57
  raw: `0x${string}`;
57
58
  };
59
+ rawPayload: `0x${string}`;
58
60
  };
59
61
  } | {
60
62
  type: "user-operation-v070";
@@ -96,11 +98,13 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
96
98
  [x: string]: unknown;
97
99
  };
98
100
  };
101
+ rawPayload: `0x${string}`;
99
102
  } | {
100
103
  type: "personal_sign";
101
104
  data: string | {
102
105
  raw: `0x${string}`;
103
106
  };
107
+ rawPayload: `0x${string}`;
104
108
  };
105
109
  } | {
106
110
  type: "authorization";
@@ -111,6 +115,7 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
111
115
  };
112
116
  signatureRequest: {
113
117
  type: "eip7702Auth";
118
+ rawPayload: `0x${string}`;
114
119
  };
115
120
  })[];
116
121
  } | {
@@ -149,11 +154,13 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
149
154
  [x: string]: unknown;
150
155
  };
151
156
  };
157
+ rawPayload: `0x${string}`;
152
158
  } | {
153
159
  type: "personal_sign";
154
160
  data: string | {
155
161
  raw: `0x${string}`;
156
162
  };
163
+ rawPayload: `0x${string}`;
157
164
  };
158
165
  } | {
159
166
  type: "user-operation-v070";
@@ -195,11 +202,13 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
195
202
  [x: string]: unknown;
196
203
  };
197
204
  };
205
+ rawPayload: `0x${string}`;
198
206
  } | {
199
207
  type: "personal_sign";
200
208
  data: string | {
201
209
  raw: `0x${string}`;
202
210
  };
211
+ rawPayload: `0x${string}`;
203
212
  };
204
213
  }>;
205
214
  sendPreparedCalls: (params: SendPreparedCallsParams) => Promise<{
@@ -4,10 +4,15 @@ import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
4
4
  import { PreparedCall_Authorization } from "../../schemas.js";
5
5
  import type { Eip7702AuthCapability } from "../../capabilities/eip7702Auth.ts";
6
6
  import type { Static } from "@sinclair/typebox";
7
+ /** Checks if an address is actively delegated on-chain. */
8
+ export declare const isDelegated: (client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: {
9
+ address: Address;
10
+ delegation: Address;
11
+ }) => Promise<boolean>;
7
12
  export declare const createAuthorizationRequest: (client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: {
8
13
  address: Address;
9
14
  delegation: Address;
10
- }) => Promise<Static<typeof PreparedCall_Authorization> | undefined>;
15
+ }) => Promise<Static<typeof PreparedCall_Authorization>>;
11
16
  export declare const EIP_7702_ACCOUNT_TYPE: readonly ["ModularAccountV2"];
12
17
  type Supported7702AccountType = (typeof EIP_7702_ACCOUNT_TYPE)[number];
13
18
  export declare const SUPPORTED_DELEGATION_ADDRESSES: "0x69007702764179f14F51cdce752f4f775d74E139"[];
@@ -1,12 +1,14 @@
1
- import { concatHex, numberToHex, isAddress, } from "viem";
1
+ import { concatHex, numberToHex, isAddress, hexToNumber, } from "viem";
2
2
  import { PreparedCall_Authorization } from "../../schemas.js";
3
3
  import { InvalidRequestError } from "ox/RpcResponse";
4
- export const createAuthorizationRequest = async (client, params) => {
4
+ import { hashAuthorization } from "viem/utils";
5
+ /** Checks if an address is actively delegated on-chain. */
6
+ export const isDelegated = async (client, params) => {
5
7
  const expectedCode = concatHex(["0xef0100", params.delegation]);
6
8
  const code = (await client.getCode({ address: params.address })) ?? "0x";
7
- if (code.toLowerCase() === expectedCode.toLowerCase()) {
8
- return undefined; // Already authorized.
9
- }
9
+ return code.toLowerCase() === expectedCode.toLowerCase();
10
+ };
11
+ export const createAuthorizationRequest = async (client, params) => {
10
12
  const data = {
11
13
  address: params.delegation,
12
14
  nonce: numberToHex(await client.getTransactionCount({
@@ -19,6 +21,11 @@ export const createAuthorizationRequest = async (client, params) => {
19
21
  chainId: numberToHex(client.chain.id),
20
22
  signatureRequest: {
21
23
  type: "eip7702Auth",
24
+ rawPayload: hashAuthorization({
25
+ chainId: client.chain.id,
26
+ nonce: hexToNumber(data.nonce),
27
+ address: params.delegation,
28
+ }),
22
29
  },
23
30
  };
24
31
  };
@@ -49,13 +56,20 @@ export const parseDelegation = (eip7702AuthCapability) => {
49
56
  : getDelegationAddressForAccountType7702(eip7702AuthCapability.delegation);
50
57
  };
51
58
  export const assertValid7702AccountAddress = (fromAddress, eip7702AuthCapability) => {
52
- if (eip7702AuthCapability &&
53
- typeof eip7702AuthCapability === "object" &&
54
- "account" in eip7702AuthCapability &&
55
- eip7702AuthCapability?.account !== fromAddress) {
56
- throw new InvalidRequestError({
57
- message: `EIP-7702 delegation account ${eip7702AuthCapability.account} must match 'from' address ${fromAddress}.`,
58
- });
59
+ if (eip7702AuthCapability) {
60
+ if (typeof eip7702AuthCapability === "object" &&
61
+ "account" in eip7702AuthCapability &&
62
+ eip7702AuthCapability?.account !== fromAddress) {
63
+ throw new InvalidRequestError({
64
+ message: `EIP-7702 delegation account ${eip7702AuthCapability.account} must match 'from' address ${fromAddress}.`,
65
+ });
66
+ }
67
+ const delegation = parseDelegation(eip7702AuthCapability);
68
+ if (!isSupportedDelegationAddress7702(delegation)) {
69
+ throw new InvalidRequestError({
70
+ message: `Unsupported 7702 delegation address: ${delegation}`,
71
+ });
72
+ }
59
73
  }
60
74
  };
61
75
  //# sourceMappingURL=7702.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"7702.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/7702.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,WAAW,EAIX,SAAS,GACV,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,EAC7C,MAMC,EACD,MAAiD,EACe,EAAE;IAClE,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,UAAU,EAAE,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C;AACzE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sCAAsC,GAAG,CACpD,OAAgB,EACsB,EAAE;IACxC,OAAO,8BAA8B,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,sCAAsC,GAAG,CAC7C,WAAqC,EACY,EAAE;IACnD,OAAO,qCAAqC,CAAC,WAAW,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF,MAAM,4BAA4B,GAChC,qCAAqC,CAAC,kBAAkB,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,qBAA2D,EAC3D,EAAE;IACF,OAAO,qBAAqB,KAAK,IAAI;QACnC,CAAC,CAAC,4BAA4B;QAC9B,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC;YAC3C,CAAC,CAAC,qBAAqB,CAAC,UAAU;YAClC,CAAC,CAAC,sCAAsC,CACpC,qBAAqB,CAAC,UAAU,CACjC,CAAC;AACV,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,WAAoB,EACpB,qBAAuE,EACvE,EAAE;IACF,IACE,qBAAqB;QACrB,OAAO,qBAAqB,KAAK,QAAQ;QACzC,SAAS,IAAI,qBAAqB;QAClC,qBAAqB,EAAE,OAAO,KAAK,WAAW,EAC9C,CAAC;QACD,MAAM,IAAI,mBAAmB,CAAC;YAC5B,OAAO,EAAE,+BAA+B,qBAAqB,CAAC,OAAO,8BAA8B,WAAW,GAAG;SAClH,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SmartAccountClient, SmartContractAccount } from \"@aa-sdk/core\";\nimport {\n concatHex,\n numberToHex,\n type Address,\n type Chain,\n type Transport,\n isAddress,\n} from \"viem\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { PreparedCall_Authorization } from \"../../schemas.js\";\nimport type { Eip7702AuthCapability } from \"../../capabilities/eip7702Auth.ts\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\n\nexport const createAuthorizationRequest = async (\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: { address: Address; delegation: Address },\n): Promise<Static<typeof PreparedCall_Authorization> | undefined> => {\n const expectedCode = concatHex([\"0xef0100\", params.delegation]);\n const code = (await client.getCode({ address: params.address })) ?? \"0x\";\n if (code.toLowerCase() === expectedCode.toLowerCase()) {\n return undefined; // Already authorized.\n }\n const data = {\n address: params.delegation,\n nonce: numberToHex(\n await client.getTransactionCount({\n address: params.address,\n }),\n ),\n };\n return {\n type: \"authorization\" as const,\n data,\n chainId: numberToHex(client.chain.id),\n signatureRequest: {\n type: \"eip7702Auth\" as const,\n },\n };\n};\n\nexport const EIP_7702_ACCOUNT_TYPE = [\"ModularAccountV2\"] as const;\n\ntype Supported7702AccountType = (typeof EIP_7702_ACCOUNT_TYPE)[number];\n\nconst Eip7702AccountTypeToDelegationAddress = {\n ModularAccountV2: \"0x69007702764179f14F51cdce752f4f775d74E139\",\n} as const satisfies Record<Supported7702AccountType, Address>;\n\nconst DelegationAddressToAccountType: Record<\n Address,\n Supported7702AccountType\n> = Object.fromEntries(\n Object.entries(Eip7702AccountTypeToDelegationAddress).map(([key, value]) => [\n value,\n key,\n ]),\n) as Record<Address, Supported7702AccountType>;\n\nexport const SUPPORTED_DELEGATION_ADDRESSES = Object.values(\n Eip7702AccountTypeToDelegationAddress,\n);\n\nexport const isSupportedDelegationAddress7702 = (address: Address): boolean => {\n return (SUPPORTED_DELEGATION_ADDRESSES as Address[]).includes(address);\n};\n\nexport const getAccountTypeForDelegationAddress7702 = (\n address: Address,\n): Supported7702AccountType | undefined => {\n return DelegationAddressToAccountType[address];\n};\n\nconst getDelegationAddressForAccountType7702 = (\n accountType: Supported7702AccountType,\n): (typeof SUPPORTED_DELEGATION_ADDRESSES)[number] => {\n return Eip7702AccountTypeToDelegationAddress[accountType];\n};\n\nconst DEFAULT_7702_DELEGATION_ADDR =\n Eip7702AccountTypeToDelegationAddress[\"ModularAccountV2\"];\n\nexport const parseDelegation = (\n eip7702AuthCapability: Static<typeof Eip7702AuthCapability>,\n) => {\n return eip7702AuthCapability === true\n ? DEFAULT_7702_DELEGATION_ADDR\n : isAddress(eip7702AuthCapability.delegation)\n ? eip7702AuthCapability.delegation\n : getDelegationAddressForAccountType7702(\n eip7702AuthCapability.delegation,\n );\n};\n\nexport const assertValid7702AccountAddress = (\n fromAddress: Address,\n eip7702AuthCapability: Static<typeof Eip7702AuthCapability> | undefined,\n) => {\n if (\n eip7702AuthCapability &&\n typeof eip7702AuthCapability === \"object\" &&\n \"account\" in eip7702AuthCapability &&\n eip7702AuthCapability?.account !== fromAddress\n ) {\n throw new InvalidRequestError({\n message: `EIP-7702 delegation account ${eip7702AuthCapability.account} must match 'from' address ${fromAddress}.`,\n });\n }\n};\n"]}
1
+ {"version":3,"file":"7702.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/7702.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,WAAW,EAIX,SAAS,EACT,WAAW,GACZ,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC9B,MAMC,EACD,MAAiD,EAC/B,EAAE;IACpB,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAChE,MAAM,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC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AAE;aAC9D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SmartAccountClient, SmartContractAccount } from \"@aa-sdk/core\";\nimport {\n concatHex,\n numberToHex,\n type Address,\n type Chain,\n type Transport,\n isAddress,\n hexToNumber,\n} from \"viem\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { PreparedCall_Authorization } from \"../../schemas.js\";\nimport type { Eip7702AuthCapability } from \"../../capabilities/eip7702Auth.ts\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\nimport { hashAuthorization } from \"viem/utils\";\n\n/** Checks if an address is actively delegated on-chain. */\nexport const isDelegated = async (\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: { address: Address; delegation: Address },\n): Promise<boolean> => {\n const expectedCode = concatHex([\"0xef0100\", params.delegation]);\n const code = (await client.getCode({ address: params.address })) ?? \"0x\";\n return code.toLowerCase() === expectedCode.toLowerCase();\n};\n\nexport const createAuthorizationRequest = async (\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: { address: Address; delegation: Address },\n): Promise<Static<typeof PreparedCall_Authorization>> => {\n const data = {\n address: params.delegation,\n nonce: numberToHex(\n await client.getTransactionCount({\n address: params.address,\n }),\n ),\n };\n return {\n type: \"authorization\" as const,\n data,\n chainId: numberToHex(client.chain.id),\n signatureRequest: {\n type: \"eip7702Auth\" as const,\n rawPayload: hashAuthorization({\n chainId: client.chain.id,\n nonce: hexToNumber(data.nonce),\n address: params.delegation,\n }),\n },\n };\n};\n\nexport const EIP_7702_ACCOUNT_TYPE = [\"ModularAccountV2\"] as const;\n\ntype Supported7702AccountType = (typeof EIP_7702_ACCOUNT_TYPE)[number];\n\nconst Eip7702AccountTypeToDelegationAddress = {\n ModularAccountV2: \"0x69007702764179f14F51cdce752f4f775d74E139\",\n} as const satisfies Record<Supported7702AccountType, Address>;\n\nconst DelegationAddressToAccountType: Record<\n Address,\n Supported7702AccountType\n> = Object.fromEntries(\n Object.entries(Eip7702AccountTypeToDelegationAddress).map(([key, value]) => [\n value,\n key,\n ]),\n) as Record<Address, Supported7702AccountType>;\n\nexport const SUPPORTED_DELEGATION_ADDRESSES = Object.values(\n Eip7702AccountTypeToDelegationAddress,\n);\n\nexport const isSupportedDelegationAddress7702 = (address: Address): boolean => {\n return (SUPPORTED_DELEGATION_ADDRESSES as Address[]).includes(address);\n};\n\nexport const getAccountTypeForDelegationAddress7702 = (\n address: Address,\n): Supported7702AccountType | undefined => {\n return DelegationAddressToAccountType[address];\n};\n\nconst getDelegationAddressForAccountType7702 = (\n accountType: Supported7702AccountType,\n): (typeof SUPPORTED_DELEGATION_ADDRESSES)[number] => {\n return Eip7702AccountTypeToDelegationAddress[accountType];\n};\n\nconst DEFAULT_7702_DELEGATION_ADDR =\n Eip7702AccountTypeToDelegationAddress[\"ModularAccountV2\"];\n\nexport const parseDelegation = (\n eip7702AuthCapability: Static<typeof Eip7702AuthCapability>,\n) => {\n return eip7702AuthCapability === true\n ? DEFAULT_7702_DELEGATION_ADDR\n : isAddress(eip7702AuthCapability.delegation)\n ? eip7702AuthCapability.delegation\n : getDelegationAddressForAccountType7702(\n eip7702AuthCapability.delegation,\n );\n};\n\nexport const assertValid7702AccountAddress = (\n fromAddress: Address,\n eip7702AuthCapability: Static<typeof Eip7702AuthCapability> | undefined,\n) => {\n if (eip7702AuthCapability) {\n if (\n typeof eip7702AuthCapability === \"object\" &&\n \"account\" in eip7702AuthCapability &&\n eip7702AuthCapability?.account !== fromAddress\n ) {\n throw new InvalidRequestError({\n message: `EIP-7702 delegation account ${eip7702AuthCapability.account} must match 'from' address ${fromAddress}.`,\n });\n }\n\n const delegation = parseDelegation(eip7702AuthCapability);\n\n if (!isSupportedDelegationAddress7702(delegation)) {\n throw new InvalidRequestError({\n message: `Unsupported 7702 delegation address: ${delegation}`,\n });\n }\n }\n};\n"]}
@@ -20,4 +20,5 @@ type CreateAccountParams = {
20
20
  */
21
21
  export declare function createAccount(params: CreateAccountParams): Promise<SmartContractAccount>;
22
22
  export declare function isModularAccountV2(account: SmartContractAccount): account is ModularAccountV2;
23
+ export declare function prepareInitialOwners(initialOwners: Address[], signerAddress: Address): Address[];
23
24
  export {};
@@ -1,10 +1,10 @@
1
- import { createModularAccountV2, } from "@account-kit/smart-contracts";
2
- import { concatHex, hexToNumber } from "viem";
1
+ import { createLightAccount, createModularAccountV2, createMultiOwnerLightAccount, createMultiOwnerModularAccount, } from "@account-kit/smart-contracts";
2
+ import { concatHex, hexToBigInt, hexToNumber, zeroAddress } 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 { InternalError } from "ox/RpcResponse";
7
6
  import { PermissionsCapability } from "../../capabilities/permissions/index.js";
7
+ import { InternalError, InvalidRequestError } from "ox/RpcResponse";
8
8
  /**
9
9
  * Creates a smart account instance from the given parameters.
10
10
  * @param params - The parameters for creating a smart account.
@@ -12,30 +12,8 @@ import { PermissionsCapability } from "../../capabilities/permissions/index.js";
12
12
  */
13
13
  export async function createAccount(params) {
14
14
  const { counterfactualInfo: ci, ...accountParams } = params;
15
- const mode = params.delegation ? "7702" : "default";
16
- if (mode === "default") {
17
- if (!ci) {
18
- throw new InternalError({
19
- message: "Counterfactual info not found",
20
- });
21
- }
22
- if (ci.factoryType !== "MAv2.0.0-sma-b") {
23
- throw new InternalError({
24
- message: `Factory type ${ci.factoryType} is not currently supported.`,
25
- });
26
- }
27
- }
28
- else if (mode === "7702") {
29
- const accountType = getAccountTypeForDelegationAddress7702(params.delegation);
30
- if (accountType !== "ModularAccountV2") {
31
- throw new InternalError({
32
- message: "7702 mode currently only supports ModularAccountV2",
33
- });
34
- }
35
- }
36
- else {
37
- assertNever(mode, "Unexpected mode in createAccount");
38
- }
15
+ // This throws if we pass a permission context and the account is not MA-v2
16
+ // TODO: test that this edge case is handled correctly
39
17
  const parsedContext = parsePermissionsContext(params.permissions, ci, params.delegation);
40
18
  const signerEntity = parsedContext?.contextVersion === "NON_DEFERRED_ACTION"
41
19
  ? {
@@ -43,16 +21,100 @@ export async function createAccount(params) {
43
21
  isGlobalValidation: parsedContext.isGlobalValidation,
44
22
  }
45
23
  : undefined;
46
- // TODO: clean this up to support different account types.
47
- return createModularAccountV2({
24
+ const mode = params.delegation ? "7702" : "default";
25
+ if (mode === "7702") {
26
+ const accountType = getAccountTypeForDelegationAddress7702(params.delegation);
27
+ if (accountType !== "ModularAccountV2") {
28
+ throw new Error("7702 mode currently only supports ModularAccountV2");
29
+ }
30
+ return createModularAccountV2({
31
+ ...accountParams,
32
+ signerEntity,
33
+ deferredAction: parsedContext?.deferredAction,
34
+ mode,
35
+ });
36
+ }
37
+ if (mode !== "default") {
38
+ return assertNever(mode, "Unexpected mode in createAccount");
39
+ }
40
+ // At this point, we are guaranteed to be in default mode, where ci
41
+ // (counterfactualInfo) must be defined
42
+ if (!ci) {
43
+ throw new InternalError({
44
+ message: "Counterfactual info not found",
45
+ });
46
+ }
47
+ const factoryType = ci.factoryType;
48
+ const commonParams = {
48
49
  ...accountParams,
49
- signerEntity,
50
- deferredAction: parsedContext?.deferredAction,
51
- initCode: ci ? concatHex([ci.factoryAddress, ci.factoryData]) : undefined,
52
- mode,
53
- });
50
+ initCode: concatHex([ci.factoryAddress, ci.factoryData]),
51
+ };
52
+ // Return the account created based on the factory type
53
+ switch (factoryType) {
54
+ case "MAv2.0.0-sma-b":
55
+ return createModularAccountV2({
56
+ ...commonParams,
57
+ signerEntity,
58
+ deferredAction: parsedContext?.deferredAction,
59
+ mode,
60
+ });
61
+ case "LightAccountV2.0.0":
62
+ return createLightAccount({
63
+ ...commonParams,
64
+ version: "v2.0.0",
65
+ });
66
+ case "LightAccountV1.0.1":
67
+ return createLightAccount({
68
+ ...commonParams,
69
+ version: "v1.0.1",
70
+ });
71
+ case "LightAccountV1.0.2":
72
+ return createLightAccount({
73
+ ...commonParams,
74
+ version: "v1.0.2",
75
+ });
76
+ case "LightAccountV1.1.0":
77
+ return createLightAccount({
78
+ ...commonParams,
79
+ version: "v1.1.0",
80
+ });
81
+ case "MAv1.0.0-MultiOwner":
82
+ return createMultiOwnerModularAccount({
83
+ ...commonParams,
84
+ });
85
+ case "LightAccountV2.0.0-MultiOwner":
86
+ return createMultiOwnerLightAccount({
87
+ ...commonParams,
88
+ version: "v2.0.0",
89
+ });
90
+ case "MAv1.0.0-MultiSig":
91
+ case "MAv2.0.0-ma-ssv":
92
+ case "MAv2.0.0-ma-webauthn":
93
+ case "unknown":
94
+ case undefined:
95
+ throw new InvalidRequestError({
96
+ message: `Account type currently unsupported: ${factoryType}`,
97
+ });
98
+ default:
99
+ return assertNever(factoryType, "Unsupported factory type");
100
+ }
54
101
  }
55
102
  export function isModularAccountV2(account) {
56
103
  return account.source === "ModularAccountV2";
57
104
  }
105
+ // Performs basic checks on the initialOwners array and returns a new array with the signer address added if not present.
106
+ // Pulled from MAv1 support in Account Kit.
107
+ export function prepareInitialOwners(initialOwners, signerAddress) {
108
+ const preparedOwners = Array.from(new Set([...initialOwners, signerAddress])).sort((a, b) => {
109
+ const bigintA = hexToBigInt(a);
110
+ const bigintB = hexToBigInt(b);
111
+ return bigintA < bigintB ? -1 : bigintA > bigintB ? 1 : 0;
112
+ });
113
+ if (preparedOwners.some((x) => x === zeroAddress)) {
114
+ throw new InvalidRequestError({
115
+ message: "Initial owners cannot contain the zero address",
116
+ });
117
+ }
118
+ return preparedOwners;
119
+ }
58
120
  //# sourceMappingURL=createAccount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/createAccount.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,GAEvB,MAAM,8BAA8B,C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ACxD,CAAC;IAED,MAAM,aAAa,GAAG,uBAAuB,CAC3C,MAAM,CAAC,WAAW,EAClB,EAAE,EACF,MAAM,CAAC,UAAU,CAClB,CAAC;IAEF,MAAM,YAAY,GAChB,aAAa,EAAE,cAAc,KAAK,qBAAqB;QACrD,CAAC,CAAC;YACE,QAAQ,EAAE,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC;YAC7C,kBAAkB,EAAE,aAAa,CAAC,kBAAkB;SACrD;QACH,CAAC,CAAC,SAAS,CAAC;IAEhB,0DAA0D;IAC1D,OAAO,sBAAsB,CAAC;QAC5B,GAAG,aAAa;QAChB,YAAY;QACZ,cAAc,EAAE,aAAa,EAAE,cAAc;QAC7C,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QACzE,IAAI;KACL,CAAC,CAAC;AACL,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 createModularAccountV2,\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 type { TypeSerializedInitcode } from \"../../schemas.js\";\nimport { parsePermissionsContext } from \"./parsePermissionsContext.js\";\nimport { assertNever } from \"../../utils.js\";\nimport { getAccountTypeForDelegationAddress7702 } from \"./7702.js\";\nimport { InternalError } from \"ox/RpcResponse\";\nimport { PermissionsCapability } from \"../../capabilities/permissions/index.js\";\n\ntype CreateAccountParams = {\n chain: Chain;\n transport: Transport;\n signer: SmartAccountSigner;\n accountAddress: Address;\n counterfactualInfo?: StaticDecode<typeof TypeSerializedInitcode>; // 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 const mode = params.delegation ? \"7702\" : \"default\";\n\n if (mode === \"default\") {\n if (!ci) {\n throw new InternalError({\n message: \"Counterfactual info not found\",\n });\n }\n if (ci.factoryType !== \"MAv2.0.0-sma-b\") {\n throw new InternalError({\n message: `Factory type ${ci.factoryType} is not currently supported.`,\n });\n }\n } else if (mode === \"7702\") {\n const accountType = getAccountTypeForDelegationAddress7702(\n params.delegation!,\n );\n if (accountType !== \"ModularAccountV2\") {\n throw new InternalError({\n message: \"7702 mode currently only supports ModularAccountV2\",\n });\n }\n } else {\n assertNever(mode, \"Unexpected mode in createAccount\");\n }\n\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 // TODO: clean this up to support different account types.\n return createModularAccountV2({\n ...accountParams,\n signerEntity,\n deferredAction: parsedContext?.deferredAction,\n initCode: ci ? concatHex([ci.factoryAddress, ci.factoryData]) : undefined,\n mode,\n });\n}\n\nexport function isModularAccountV2(\n account: SmartContractAccount,\n): account is ModularAccountV2 {\n return account.source === \"ModularAccountV2\";\n}\n"]}
1
+ {"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/createAccount.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,8BAA8B,GAE/B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,WA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AC","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, hexToBigInt, hexToNumber, zeroAddress } from \"viem\";\nimport type { TypeSerializedInitcode } from \"../../schemas.js\";\nimport { parsePermissionsContext } from \"./parsePermissionsContext.js\";\nimport { assertNever } from \"../../utils.js\";\nimport { getAccountTypeForDelegationAddress7702 } from \"./7702.js\";\nimport { PermissionsCapability } from \"../../capabilities/permissions/index.js\";\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 TypeSerializedInitcode>; // 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\n// Performs basic checks on the initialOwners array and returns a new array with the signer address added if not present.\n// Pulled from MAv1 support in Account Kit.\nexport function prepareInitialOwners(\n initialOwners: Address[],\n signerAddress: Address,\n): Address[] {\n const preparedOwners = Array.from(\n new Set([...initialOwners, signerAddress]),\n ).sort((a, b) => {\n const bigintA = hexToBigInt(a);\n const bigintB = hexToBigInt(b);\n\n return bigintA < bigintB ? -1 : bigintA > bigintB ? 1 : 0;\n });\n\n if (preparedOwners.some((x) => x === zeroAddress)) {\n throw new InvalidRequestError({\n message: \"Initial owners cannot contain the zero address\",\n });\n }\n\n return preparedOwners;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { StaticDecode } from "@sinclair/typebox";
2
+ import type { TypeSerializedInitcode } from "../../schemas.ts";
3
+ export type Feature = "permissions";
4
+ export declare function supportsFeature(counterfactualInfo: StaticDecode<typeof TypeSerializedInitcode>, feature: Feature): boolean;
@@ -0,0 +1,21 @@
1
+ const supportedFeatures = {
2
+ "LightAccountV1.0.1": [],
3
+ "LightAccountV1.0.2": [],
4
+ "LightAccountV1.1.0": [],
5
+ "LightAccountV2.0.0": [],
6
+ "LightAccountV2.0.0-MultiOwner": [],
7
+ "MAv1.0.0-MultiOwner": [],
8
+ "MAv1.0.0-MultiSig": [],
9
+ "MAv2.0.0-sma-b": ["permissions"],
10
+ "MAv2.0.0-ma-ssv": ["permissions"],
11
+ "MAv2.0.0-ma-webauthn": [],
12
+ unknown: [],
13
+ };
14
+ export function supportsFeature(counterfactualInfo, feature) {
15
+ const factorySupportedFeatures = supportedFeatures[counterfactualInfo.factoryType];
16
+ if (factorySupportedFeatures === undefined) {
17
+ throw new Error("Unsupported FactoryType: " + counterfactualInfo.factoryType);
18
+ }
19
+ return factorySupportedFeatures.includes(feature);
20
+ }
21
+ //# sourceMappingURL=supportsFeature.js.map
@@ -0,0 +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,kBAA+D,EAC/D,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 { TypeSerializedInitcode } from \"../../schemas.ts\";\n\nexport type Feature = \"permissions\";\n\ntype FactoryType = StaticDecode<typeof TypeSerializedInitcode>[\"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 TypeSerializedInitcode>,\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"]}