@account-kit/wallet-client 0.0.1-alpha.1 → 0.1.0-alpha.1

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 (151) hide show
  1. package/dist/esm/abi/index.d.ts +8 -8
  2. package/dist/esm/abi/index.js +8 -8
  3. package/dist/esm/abi/index.js.map +1 -1
  4. package/dist/esm/capabilities/index.d.ts +23 -0
  5. package/dist/esm/capabilities/index.js +4 -2
  6. package/dist/esm/capabilities/index.js.map +1 -1
  7. package/dist/esm/capabilities/overrides.d.ts +26 -0
  8. package/dist/esm/capabilities/overrides.js +14 -0
  9. package/dist/esm/capabilities/overrides.js.map +1 -0
  10. package/dist/esm/capabilities/permissions/index.d.ts +57 -17
  11. package/dist/esm/capabilities/permissions/index.js +26 -15
  12. package/dist/esm/capabilities/permissions/index.js.map +1 -1
  13. package/dist/esm/capabilities/permissions/mav2.js +1 -1
  14. package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
  15. package/dist/esm/client/actions/grantPermissions.d.ts +1 -1
  16. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  17. package/dist/esm/client/actions/requestAccount.d.ts +2 -2
  18. package/dist/esm/client/actions/requestAccount.js +2 -2
  19. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  20. package/dist/esm/client/actions/sendPreparedCalls.d.ts +2 -2
  21. package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
  22. package/dist/esm/client/actions/signMessage.d.ts +1 -1
  23. package/dist/esm/client/actions/signMessage.js +1 -1
  24. package/dist/esm/client/actions/signMessage.js.map +1 -1
  25. package/dist/esm/client/actions/signSignatureRequest.d.ts +1 -1
  26. package/dist/esm/client/actions/signSignatureRequest.js +2 -2
  27. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  28. package/dist/esm/client/actions/signTypedData.d.ts +1 -1
  29. package/dist/esm/client/actions/signTypedData.js +1 -1
  30. package/dist/esm/client/actions/signTypedData.js.map +1 -1
  31. package/dist/esm/client/client.e2e-test.js +5 -6
  32. package/dist/esm/client/client.e2e-test.js.map +1 -1
  33. package/dist/esm/client/decorator.d.ts +8 -8
  34. package/dist/esm/client/decorator.js +10 -10
  35. package/dist/esm/client/decorator.js.map +1 -1
  36. package/dist/esm/client/index.d.ts +1 -1
  37. package/dist/esm/client/index.js +3 -3
  38. package/dist/esm/client/index.js.map +1 -1
  39. package/dist/esm/exports/index.d.ts +13 -13
  40. package/dist/esm/exports/index.js +13 -13
  41. package/dist/esm/exports/index.js.map +1 -1
  42. package/dist/esm/exports/internal.d.ts +12 -12
  43. package/dist/esm/exports/internal.js +11 -11
  44. package/dist/esm/exports/internal.js.map +1 -1
  45. package/dist/esm/isomorphic/actions/createSession.d.ts +3 -3
  46. package/dist/esm/isomorphic/actions/createSession.js +7 -5
  47. package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
  48. package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +2 -2
  49. package/dist/esm/isomorphic/actions/getCallsStatus.js +3 -3
  50. package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
  51. package/dist/esm/isomorphic/actions/prepareCalls.d.ts +2 -2
  52. package/dist/esm/isomorphic/actions/prepareCalls.js +4 -3
  53. package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
  54. package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +4 -4
  55. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +3 -3
  56. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
  57. package/dist/esm/isomorphic/client.d.ts +8 -7
  58. package/dist/esm/isomorphic/client.js +15 -8
  59. package/dist/esm/isomorphic/client.js.map +1 -1
  60. package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -2
  61. package/dist/esm/isomorphic/utils/createAccount.js +1 -1
  62. package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
  63. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +4 -4
  64. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +1 -1
  65. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
  66. package/dist/esm/local/client.js +6 -5
  67. package/dist/esm/local/client.js.map +1 -1
  68. package/dist/esm/remote/client.js +3 -3
  69. package/dist/esm/remote/client.js.map +1 -1
  70. package/dist/esm/rpc/request.d.ts +32 -9
  71. package/dist/esm/rpc/request.js +17 -7
  72. package/dist/esm/rpc/request.js.map +1 -1
  73. package/dist/esm/rpc/schema.d.ts +32 -9
  74. package/dist/esm/rpc/schema.js +1 -1
  75. package/dist/esm/rpc/schema.js.map +1 -1
  76. package/dist/types/abi/index.d.ts +8 -8
  77. package/dist/types/abi/index.d.ts.map +1 -1
  78. package/dist/types/capabilities/index.d.ts +23 -0
  79. package/dist/types/capabilities/index.d.ts.map +1 -1
  80. package/dist/types/capabilities/overrides.d.ts +27 -0
  81. package/dist/types/capabilities/overrides.d.ts.map +1 -0
  82. package/dist/types/capabilities/permissions/index.d.ts +57 -17
  83. package/dist/types/capabilities/permissions/index.d.ts.map +1 -1
  84. package/dist/types/client/actions/grantPermissions.d.ts +1 -1
  85. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  86. package/dist/types/client/actions/requestAccount.d.ts +2 -2
  87. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  88. package/dist/types/client/actions/sendPreparedCalls.d.ts +2 -2
  89. package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
  90. package/dist/types/client/actions/signMessage.d.ts +1 -1
  91. package/dist/types/client/actions/signMessage.d.ts.map +1 -1
  92. package/dist/types/client/actions/signSignatureRequest.d.ts +1 -1
  93. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  94. package/dist/types/client/actions/signTypedData.d.ts +1 -1
  95. package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
  96. package/dist/types/client/decorator.d.ts +8 -8
  97. package/dist/types/client/decorator.d.ts.map +1 -1
  98. package/dist/types/client/index.d.ts +1 -1
  99. package/dist/types/client/index.d.ts.map +1 -1
  100. package/dist/types/exports/index.d.ts +13 -13
  101. package/dist/types/exports/index.d.ts.map +1 -1
  102. package/dist/types/exports/internal.d.ts +12 -12
  103. package/dist/types/exports/internal.d.ts.map +1 -1
  104. package/dist/types/isomorphic/actions/createSession.d.ts +3 -3
  105. package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
  106. package/dist/types/isomorphic/actions/getCallsStatus.d.ts +2 -2
  107. package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -1
  108. package/dist/types/isomorphic/actions/prepareCalls.d.ts +2 -2
  109. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
  110. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +4 -4
  111. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
  112. package/dist/types/isomorphic/client.d.ts +8 -7
  113. package/dist/types/isomorphic/client.d.ts.map +1 -1
  114. package/dist/types/isomorphic/utils/createAccount.d.ts +2 -2
  115. package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
  116. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +4 -4
  117. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
  118. package/dist/types/local/client.d.ts.map +1 -1
  119. package/dist/types/remote/client.d.ts.map +1 -1
  120. package/dist/types/rpc/request.d.ts +32 -9
  121. package/dist/types/rpc/request.d.ts.map +1 -1
  122. package/dist/types/rpc/schema.d.ts +32 -9
  123. package/dist/types/rpc/schema.d.ts.map +1 -1
  124. package/package.json +8 -3
  125. package/src/abi/index.ts +8 -8
  126. package/src/capabilities/index.ts +4 -2
  127. package/src/capabilities/overrides.ts +20 -0
  128. package/src/capabilities/permissions/index.ts +42 -24
  129. package/src/capabilities/permissions/mav2.ts +1 -1
  130. package/src/client/actions/grantPermissions.ts +1 -1
  131. package/src/client/actions/requestAccount.ts +4 -4
  132. package/src/client/actions/sendPreparedCalls.ts +3 -3
  133. package/src/client/actions/signMessage.ts +2 -2
  134. package/src/client/actions/signSignatureRequest.ts +2 -2
  135. package/src/client/actions/signTypedData.ts +2 -2
  136. package/src/client/client.e2e-test.ts +5 -6
  137. package/src/client/decorator.ts +19 -19
  138. package/src/client/index.ts +6 -3
  139. package/src/exports/index.ts +13 -13
  140. package/src/exports/internal.ts +12 -12
  141. package/src/isomorphic/actions/createSession.ts +18 -14
  142. package/src/isomorphic/actions/getCallsStatus.ts +6 -6
  143. package/src/isomorphic/actions/prepareCalls.ts +7 -6
  144. package/src/isomorphic/actions/sendPreparedCalls.ts +7 -7
  145. package/src/isomorphic/client.ts +24 -11
  146. package/src/isomorphic/utils/createAccount.ts +3 -3
  147. package/src/isomorphic/utils/parsePermissionsContext.ts +3 -3
  148. package/src/local/client.ts +9 -8
  149. package/src/remote/client.ts +3 -3
  150. package/src/rpc/request.ts +33 -18
  151. package/src/rpc/schema.ts +3 -3
@@ -1,7 +1,7 @@
1
1
  import { deepHexlify, } from "@aa-sdk/core";
2
- import { custom, fromHex, zeroAddress, ChainNotFoundError, toHex, } from "viem";
3
- import { createAccount } from "../utils/createAccount";
4
- import { createDummySigner } from "../utils/createDummySigner";
2
+ import { ChainNotFoundError, custom, fromHex, toHex, zeroAddress, } from "viem";
3
+ import { createAccount } from "../utils/createAccount.js";
4
+ import { createDummySigner } from "../utils/createDummySigner.js";
5
5
  // TODO: handle capabilities like permissions and paymaster here
6
6
  export async function prepareCalls(client, params) {
7
7
  if (!client.chain) {
@@ -37,6 +37,7 @@ export async function prepareCalls(client, params) {
37
37
  value: x.value ? fromHex(x.value, "bigint") : undefined,
38
38
  })),
39
39
  account,
40
+ overrides: params.capabilities?.gasParamsOverride,
40
41
  });
41
42
  const uoRequest = deepHexlify(builtUo);
42
43
  const hash = account.getEntryPoint().getUserOperationHash(uoRequest);
@@ -1 +1 @@
1
- {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareCalls.ts"],"names":[],"mappings":"AAA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,EAAE;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI;YACpB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;SACxD,CAAC,CAAC;QACH,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAEvC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAErE,OAAO;QACL,IAAI,EACF,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;YACzC,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,qBAAqB;QAC3B,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,gBAAgB,EAAE;YAChB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE;gBACJ,GAAG,EAAE,IAAI;aACV;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n deepHexlify,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport {\n custom,\n fromHex,\n zeroAddress,\n type Chain,\n type Transport,\n ChainNotFoundError,\n toHex,\n} from \"viem\";\nimport type { wallet_prepareCalls } from \"../../rpc/request\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema\";\nimport { createAccount } from \"../utils/createAccount\";\nimport { createDummySigner } from \"../utils/createDummySigner\";\n\nexport type PrepareCallsParams = Omit<\n Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\n\nexport type PrepareCallsResult = Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"ReturnType\"]\n>;\n\n// TODO: handle capabilities like permissions and paymaster here\nexport async function prepareCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n // in local mode, we probably want some kind of caching for this\n const { counterfactualInfo } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.from,\n includeCounterfactualInfo: true,\n },\n ],\n });\n if (!counterfactualInfo) {\n throw new Error(\"No counterfactual info found.\");\n }\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(zeroAddress),\n accountAddress: params.from,\n counterfactualInfo,\n capabilities: params.capabilities,\n });\n\n // TODO: oops we don't actually support setting the policyId as an override here\n // if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly\n const builtUo = await client.buildUserOperation({\n uo: params.calls.map((x) => ({\n target: x.to,\n data: x.data ?? \"0x\",\n value: x.value ? fromHex(x.value, \"bigint\") : undefined,\n })),\n account,\n });\n\n const uoRequest = deepHexlify(builtUo);\n\n const hash = account.getEntryPoint().getUserOperationHash(uoRequest);\n\n return {\n type:\n account.getEntryPoint().version === \"0.7.0\"\n ? \"user-operation-v070\"\n : \"user-operation-v060\",\n data: uoRequest,\n chainId: toHex(client.chain.id),\n signatureRequest: {\n type: \"personal_sign\",\n data: {\n raw: hash,\n },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAGZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,KAAK,EACL,WAAW,GAGZ,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA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CAAC,YAAY,EAAE,iBAAiB;KAClD,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAEvC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAErE,OAAO;QACL,IAAI,EACF,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;YACzC,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,qBAAqB;QAC3B,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,gBAAgB,EAAE;YAChB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE;gBACJ,GAAG,EAAE,IAAI;aACV;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n deepHexlify,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport {\n ChainNotFoundError,\n custom,\n fromHex,\n toHex,\n zeroAddress,\n type Chain,\n type Transport,\n} from \"viem\";\nimport type { wallet_prepareCalls } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { createAccount } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\n\nexport type PrepareCallsParams = Omit<\n Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\n\nexport type PrepareCallsResult = Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"ReturnType\"]\n>;\n\n// TODO: handle capabilities like permissions and paymaster here\nexport async function prepareCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n // in local mode, we probably want some kind of caching for this\n const { counterfactualInfo } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.from,\n includeCounterfactualInfo: true,\n },\n ],\n });\n if (!counterfactualInfo) {\n throw new Error(\"No counterfactual info found.\");\n }\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(zeroAddress),\n accountAddress: params.from,\n counterfactualInfo,\n capabilities: params.capabilities,\n });\n\n // TODO: oops we don't actually support setting the policyId as an override here\n // if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly\n const builtUo = await client.buildUserOperation({\n uo: params.calls.map((x) => ({\n target: x.to,\n data: x.data ?? \"0x\",\n value: x.value ? fromHex(x.value, \"bigint\") : undefined,\n })),\n account,\n overrides: params.capabilities?.gasParamsOverride,\n });\n\n const uoRequest = deepHexlify(builtUo);\n\n const hash = account.getEntryPoint().getUserOperationHash(uoRequest);\n\n return {\n type:\n account.getEntryPoint().version === \"0.7.0\"\n ? \"user-operation-v070\"\n : \"user-operation-v060\",\n data: uoRequest,\n chainId: toHex(client.chain.id),\n signatureRequest: {\n type: \"personal_sign\",\n data: {\n raw: hash,\n },\n },\n };\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
2
+ import type { Static, StaticDecode } from "@sinclair/typebox";
2
3
  import { type Chain, type Transport } from "viem";
3
- import type { wallet_sendPreparedCalls } from "../../rpc/request";
4
- import type { WalletServerViemRpcSchema } from "../../rpc/schema";
5
- import type { Static } from "@sinclair/typebox";
6
- export type SendPreparedCallsParams = Omit<Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0], "chainId">;
4
+ import type { wallet_sendPreparedCalls } from "../../rpc/request.js";
5
+ import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
6
+ export type SendPreparedCallsParams = Omit<StaticDecode<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0], "chainId">;
7
7
  export type SendPreparedCallsResult = Static<(typeof wallet_sendPreparedCalls)["properties"]["ReturnType"]>;
8
8
  export declare function sendPreparedCalls(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;
@@ -1,8 +1,8 @@
1
1
  import { getEntryPoint, } from "@aa-sdk/core";
2
- import { ChainNotFoundError, concat, concatHex, toHex, } from "viem";
3
- import { decodePermissionsContext } from "../../capabilities/permissions/mav2";
4
2
  import { Value } from "@sinclair/typebox/value";
5
- import { TypeCallId } from "../../schemas";
3
+ import { ChainNotFoundError, concat, concatHex, toHex, } from "viem";
4
+ import { decodePermissionsContext } from "../../capabilities/permissions/mav2.js";
5
+ import { TypeCallId } from "../../schemas.js";
6
6
  // TODO: this only supports MAv2 right now, we need to fix this
7
7
  export async function sendPreparedCalls(client, params) {
8
8
  if (!client.chain) {
@@ -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,EACL,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAG/E,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAc3C,+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,CA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M,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import {\n getEntryPoint,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport {\n ChainNotFoundError,\n concat,\n concatHex,\n toHex,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { decodePermissionsContext } from \"../../capabilities/permissions/mav2\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport { TypeCallId } from \"../../schemas\";\nimport type { Static } from \"@sinclair/typebox\";\n\nexport type SendPreparedCallsParams = Omit<\n Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\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?.context) {\n return;\n }\n\n const decodedContext = decodePermissionsContext(\n params.capabilities.permissions.context,\n );\n\n if (decodedContext.contextVersion === \"REMOTE_MODE_DEFERRED_ACTION\") {\n throw new Error(\n \"Remote mode deferred action not supported in isomorphic client\",\n );\n }\n\n return decodedContext.deferredAction;\n })();\n\n const entryPoint =\n params.type === \"user-operation-v060\"\n ? getEntryPoint(client.chain, { version: \"0.6.0\" })\n : getEntryPoint(client.chain, { version: \"0.7.0\" });\n\n const hash = await client.sendRawUserOperation(\n {\n ...params.data,\n signature:\n deferredAction != null\n ? concatHex([\n `0x${deferredAction.slice(68)}`, // Cuts off stuff preprended to the digest (nonce, etc. that we had previously).\n \"0xff\",\n \"0x00\",\n params.signature.signature,\n ])\n : concat([\"0xFF\", \"0x00\", params.signature.signature]),\n },\n entryPoint.address,\n );\n\n const callId = Value.Encode(TypeCallId, {\n chainId: toHex(client.chain.id),\n hash,\n });\n\n return {\n preparedCallIds: [callId],\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;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAGlF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAa9C,+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,OAAO,EAAE,CAAC;YAC/C,OAAO;QACT,CAAC;QAED,MAAM,cAAc,GAAG,wBAAwB,CAC7C,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CACxC,CAAC;QAEF,IAAI,cAAc,CAAC,cAAc,KAAK,6BAA6B,EAAE,CAAC;YACpE,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QAED,OAAO,cAAc,CAAC,cAAc,CAAC;IACvC,CAAC,CAAC,EAAE,CAAC;IAEL,MAAM,UAAU,GACd,MAAM,CAAC,IAAI,KAAK,qBAAqB;QACnC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QACnD,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAExD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAC5C;QACE,GAAG,MAAM,CAAC,IAAI;QACd,SAAS,EACP,cAAc,IAAI,IAAI;YACpB,CAAC,CAAC,SAAS,CAAC;gBACR,KAAK,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,gFAAgF;gBACjH,MAAM;gBACN,MAAM;gBACN,MAAM,CAAC,SAAS,CAAC,SAAS;aAC3B,CAAC;YACJ,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;KAC3D,EACD,UAAU,CAAC,OAAO,CACnB,CAAC;IAEF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE;QACtC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,IAAI;KACL,CAAC,CAAC;IAEH,OAAO;QACL,eAAe,EAAE,CAAC,MAAM,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import {\n getEntryPoint,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static, StaticDecode } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n ChainNotFoundError,\n concat,\n concatHex,\n toHex,\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\";\n\nexport type SendPreparedCallsParams = Omit<\n StaticDecode<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\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?.context) {\n return;\n }\n\n const decodedContext = decodePermissionsContext(\n params.capabilities.permissions.context,\n );\n\n if (decodedContext.contextVersion === \"REMOTE_MODE_DEFERRED_ACTION\") {\n throw new Error(\n \"Remote mode deferred action not supported in isomorphic client\",\n );\n }\n\n return decodedContext.deferredAction;\n })();\n\n const entryPoint =\n params.type === \"user-operation-v060\"\n ? getEntryPoint(client.chain, { version: \"0.6.0\" })\n : getEntryPoint(client.chain, { version: \"0.7.0\" });\n\n const hash = await client.sendRawUserOperation(\n {\n ...params.data,\n signature:\n deferredAction != null\n ? concatHex([\n `0x${deferredAction.slice(68)}`, // Cuts off stuff preprended to the digest (nonce, etc. that we had previously).\n \"0xff\",\n \"0x00\",\n params.signature.signature,\n ])\n : concat([\"0xFF\", \"0x00\", params.signature.signature]),\n },\n entryPoint.address,\n );\n\n const callId = Value.Encode(TypeCallId, {\n chainId: toHex(client.chain.id),\n hash,\n });\n\n return {\n preparedCallIds: [callId],\n };\n}\n"]}
@@ -1,14 +1,15 @@
1
1
  import { type SmartAccountClient, type SmartAccountClientRpcSchema, type SmartContractAccount } from "@aa-sdk/core";
2
2
  import { type Chain, type Transport } from "viem";
3
- import type { WalletServerViemRpcSchema } from "../rpc/schema";
4
- import { type PrepareCallsParams } from "./actions/prepareCalls";
5
- import { type SendPreparedCallsParams } from "./actions/sendPreparedCalls";
6
- import { type GetCallsStatusParams } from "./actions/getCallsStatus";
7
- import { type CreateSessionParams } from "./actions/createSession";
3
+ import type { WalletServerViemRpcSchema } from "../rpc/schema.js";
4
+ import { type CreateSessionParams } from "./actions/createSession.js";
5
+ import { type GetCallsStatusParams } from "./actions/getCallsStatus.js";
6
+ import { type PrepareCallsParams } from "./actions/prepareCalls.js";
7
+ import { type SendPreparedCallsParams } from "./actions/sendPreparedCalls.js";
8
8
  type ClientParams = {
9
9
  chain: Chain;
10
10
  transport: Transport;
11
11
  policyId?: string;
12
+ useErc7677middleware?: boolean;
12
13
  };
13
14
  export declare function isomorphicClientActions(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>): {
14
15
  prepareCalls: (params: PrepareCallsParams) => Promise<{
@@ -90,8 +91,8 @@ export declare function isomorphicClientActions(client: SmartAccountClient<Trans
90
91
  atomic: boolean;
91
92
  status: 100 | 200 | 400 | 500 | 600;
92
93
  }>;
93
- createSession: (params: CreateSessionParams) => Promise<import("./actions/createSession").CreateSessionResult>;
94
+ createSession: (params: CreateSessionParams) => Promise<import("./actions/createSession.js").CreateSessionResult>;
94
95
  };
95
- export declare function createIsomorphicClient({ chain, transport, policyId, }: ClientParams): SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, ReturnType<typeof isomorphicClientActions>, WalletServerViemRpcSchema & SmartAccountClientRpcSchema>;
96
+ export declare function createIsomorphicClient({ chain, transport, policyId, useErc7677middleware, }: ClientParams): SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, ReturnType<typeof isomorphicClientActions>, WalletServerViemRpcSchema & SmartAccountClientRpcSchema>;
96
97
  export type IsomorphicClient = ReturnType<typeof createIsomorphicClient>;
97
98
  export {};
@@ -1,10 +1,10 @@
1
1
  import { createSmartAccountClient, } from "@aa-sdk/core";
2
- import { alchemyFeeEstimator, alchemyGasManagerMiddleware, } from "@account-kit/infra";
2
+ import { alchemyFeeEstimator, alchemyGasAndPaymasterAndDataMiddleware, alchemyGasManagerMiddleware, } from "@account-kit/infra";
3
3
  import {} from "viem";
4
- import { prepareCalls } from "./actions/prepareCalls";
5
- import { sendPreparedCalls, } from "./actions/sendPreparedCalls";
6
- import { getCallsStatus, } from "./actions/getCallsStatus";
7
- import { createSession, } from "./actions/createSession";
4
+ import { createSession, } from "./actions/createSession.js";
5
+ import { getCallsStatus, } from "./actions/getCallsStatus.js";
6
+ import { prepareCalls, } from "./actions/prepareCalls.js";
7
+ import { sendPreparedCalls, } from "./actions/sendPreparedCalls.js";
8
8
  export function isomorphicClientActions(client) {
9
9
  return {
10
10
  prepareCalls: (params) => prepareCalls(client, params),
@@ -15,15 +15,22 @@ export function isomorphicClientActions(client) {
15
15
  }
16
16
  // the isomorphic client likely won't be exposed directly. This client contains the business logic that can be run on the wallet server or on the client
17
17
  // if the dev chooses to run the client in "local" mode.
18
- export function createIsomorphicClient({ chain, transport, policyId, }) {
18
+ export function createIsomorphicClient({ chain, transport, policyId, useErc7677middleware = true, }) {
19
19
  // This must be a smart account client since as of now we use it to build UOs under the hood
20
20
  const client = createSmartAccountClient({
21
21
  transport,
22
22
  chain,
23
23
  // TODO: we will want to enforce alchemy transport here probably
24
24
  feeEstimator: alchemyFeeEstimator(transport),
25
- // TODO: we need to use the other middleware that does gas estimation as well here
26
- ...(policyId ? alchemyGasManagerMiddleware(policyId) : {}),
25
+ ...(policyId
26
+ ? useErc7677middleware
27
+ ? alchemyGasManagerMiddleware(policyId)
28
+ : // NOTE: DO NOT USE THIS MIDDLEWARE in the server, currently we require using the erc7677 middleware
29
+ alchemyGasAndPaymasterAndDataMiddleware({
30
+ policyId,
31
+ transport: transport,
32
+ })
33
+ : {}),
27
34
  }).extend(isomorphicClientActions);
28
35
  return client;
29
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/isomorphic/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;AAChB,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n type SmartAccountClient,\n type SmartAccountClientRpcSchema,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport {\n alchemyFeeEstimator,\n alchemyGasManagerMiddleware,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\nimport { type Chain, type Transport } from \"viem\";\nimport type { WalletServerViemRpcSchema } from \"../rpc/schema\";\nimport { prepareCalls, type PrepareCallsParams } from \"./actions/prepareCalls\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsParams,\n} from \"./actions/sendPreparedCalls\";\nimport {\n getCallsStatus,\n type GetCallsStatusParams,\n} from \"./actions/getCallsStatus\";\nimport {\n createSession,\n type CreateSessionParams,\n} from \"./actions/createSession\";\n\n// let's start with something that takes in as many params as possible, then we can eliminate them as we don't need them\ntype ClientParams = {\n chain: Chain;\n transport: Transport;\n policyId?: string;\n};\n\nexport function isomorphicClientActions(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n) {\n return {\n prepareCalls: (params: PrepareCallsParams) => prepareCalls(client, params),\n sendPreparedCalls: (params: SendPreparedCallsParams) =>\n sendPreparedCalls(client, params),\n getCallsStatus: (params: GetCallsStatusParams) =>\n getCallsStatus(client, params),\n createSession: (params: CreateSessionParams) =>\n createSession(client, params),\n };\n}\n\n// the isomorphic client likely won't be exposed directly. This client contains the business logic that can be run on the wallet server or on the client\n// if the dev chooses to run the client in \"local\" mode.\nexport function createIsomorphicClient({\n chain,\n transport,\n policyId,\n}: ClientParams): SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n ReturnType<typeof isomorphicClientActions>,\n WalletServerViemRpcSchema & SmartAccountClientRpcSchema\n> {\n // This must be a smart account client since as of now we use it to build UOs under the hood\n const client = createSmartAccountClient({\n transport,\n chain,\n // TODO: we will want to enforce alchemy transport here probably\n feeEstimator: alchemyFeeEstimator(transport as AlchemyTransport),\n // TODO: we need to use the other middleware that does gas estimation as well here\n ...(policyId ? alchemyGasManagerMiddleware(policyId) : {}),\n }).extend(isomorphicClientActions);\n\n return client;\n}\n\nexport type IsomorphicClient = ReturnType<typeof createIsomorphicClient>;\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/isomorphic/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAIzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,uCAAuC,EACvC,2BAA2B,GAE5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAA8B,MAAM,MAAM,CAAC;AAElD,OAAO,EACL,aAAa,GAEd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,cAAc,GAEf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,YAAY,GAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,iBAAiB,GAElB,MAAM,gCAAgC,CAAC;AAUxC,MAAM,UAAU,uBAAuB,CACrC,MAMC;IAED,OAAO;QACL,YAAY,EAAE,CAAC,MAA0B,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;QAC1E,iBAAiB,EAAE,CAAC,MAA+B,EAAE,EAAE,CACrD,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;QACnC,cAAc,EAAE,CAAC,MAA4B,EAAE,EAAE,CAC/C,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC;QAChC,aAAa,EAAE,CAAC,MAA2B,EAAE,EAAE,CAC7C,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC;KAChC,CAAC;AACJ,CAAC;AAED,wJAAwJ;AACxJ,wDAAwD;AACxD,MAAM,UAAU,sBAAsB,CAAC,EACrC,KAAK,EACL,SAAS,EACT,QAAQ,EACR,oBAAoB,GAAG,IAAI,GACd;IAOb,4FAA4F;IAC5F,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,SAAS;QACT,KAAK;QACL,gEAAgE;QAChE,YAAY,EAAE,mBAAmB,CAAC,SAA6B,CAAC;QAChE,GAAG,CAAC,QAAQ;YACV,CAAC,CAAC,oBAAoB;gBACpB,CAAC,CAAC,2BAA2B,CAAC,QAAQ,CAAC;gBACvC,CAAC,CAAC,oGAAoG;oBACpG,uCAAuC,CAAC;wBACtC,QAAQ;wBACR,SAAS,EAAE,SAA6B;qBACzC,CAAC;YACN,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAEnC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n type SmartAccountClient,\n type SmartAccountClientRpcSchema,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport {\n alchemyFeeEstimator,\n alchemyGasAndPaymasterAndDataMiddleware,\n alchemyGasManagerMiddleware,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\nimport { type Chain, type Transport } from \"viem\";\nimport type { WalletServerViemRpcSchema } from \"../rpc/schema.js\";\nimport {\n createSession,\n type CreateSessionParams,\n} from \"./actions/createSession.js\";\nimport {\n getCallsStatus,\n type GetCallsStatusParams,\n} from \"./actions/getCallsStatus.js\";\nimport {\n prepareCalls,\n type PrepareCallsParams,\n} from \"./actions/prepareCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsParams,\n} from \"./actions/sendPreparedCalls.js\";\n\n// let's start with something that takes in as many params as possible, then we can eliminate them as we don't need them\ntype ClientParams = {\n chain: Chain;\n transport: Transport;\n policyId?: string;\n useErc7677middleware?: boolean;\n};\n\nexport function isomorphicClientActions(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n) {\n return {\n prepareCalls: (params: PrepareCallsParams) => prepareCalls(client, params),\n sendPreparedCalls: (params: SendPreparedCallsParams) =>\n sendPreparedCalls(client, params),\n getCallsStatus: (params: GetCallsStatusParams) =>\n getCallsStatus(client, params),\n createSession: (params: CreateSessionParams) =>\n createSession(client, params),\n };\n}\n\n// the isomorphic client likely won't be exposed directly. This client contains the business logic that can be run on the wallet server or on the client\n// if the dev chooses to run the client in \"local\" mode.\nexport function createIsomorphicClient({\n chain,\n transport,\n policyId,\n useErc7677middleware = true,\n}: ClientParams): SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n ReturnType<typeof isomorphicClientActions>,\n WalletServerViemRpcSchema & SmartAccountClientRpcSchema\n> {\n // This must be a smart account client since as of now we use it to build UOs under the hood\n const client = createSmartAccountClient({\n transport,\n chain,\n // TODO: we will want to enforce alchemy transport here probably\n feeEstimator: alchemyFeeEstimator(transport as AlchemyTransport),\n ...(policyId\n ? useErc7677middleware\n ? alchemyGasManagerMiddleware(policyId)\n : // NOTE: DO NOT USE THIS MIDDLEWARE in the server, currently we require using the erc7677 middleware\n alchemyGasAndPaymasterAndDataMiddleware({\n policyId,\n transport: transport as AlchemyTransport,\n })\n : {}),\n }).extend(isomorphicClientActions);\n\n return client;\n}\n\nexport type IsomorphicClient = ReturnType<typeof createIsomorphicClient>;\n"]}
@@ -2,8 +2,8 @@ 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 type { TypeSerializedInitcode } from "../../schemas";
6
- import type { Capabilities } from "../../capabilities";
5
+ import type { Capabilities } from "../../capabilities/index.js";
6
+ import type { TypeSerializedInitcode } from "../../schemas.js";
7
7
  type CreateAccountParams = {
8
8
  chain: Chain;
9
9
  transport: Transport;
@@ -1,6 +1,6 @@
1
1
  import { createModularAccountV2, } from "@account-kit/smart-contracts";
2
2
  import { concatHex, hexToNumber } from "viem";
3
- import { parsePermissionsContext } from "./parsePermissionsContext";
3
+ import { parsePermissionsContext } from "./parsePermissionsContext.js";
4
4
  /**
5
5
  * Creates a smart account instance from the given parameters.
6
6
  * @param params - The parameters for creating a smart account.
@@ -1 +1 @@
1
- {"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/createAccount.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,GAEvB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAG9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAWpE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA2B;IAE3B,MAAM,EAAE,kBAAkB,EAAE,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC;IAC5D,mDAAmD;IACnD,IAAI,EAAE,CAAC,WAAW,KAAK,gBAAgB,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,aAAa,GAAG,uBAAuB,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAEvE,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,OAAO,sBAAsB,CAAC;QAC5B,GAAG,aAAa;QAChB,YAAY;QACZ,cAAc,EAAE,aAAa,EAAE,cAAc;QAC7C,QAAQ,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;KACzD,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\";\nimport type { Capabilities } from \"../../capabilities\";\nimport { parsePermissionsContext } from \"./parsePermissionsContext\";\n\ntype CreateAccountParams = {\n chain: Chain;\n transport: Transport;\n signer: SmartAccountSigner;\n accountAddress: Address;\n counterfactualInfo: StaticDecode<typeof TypeSerializedInitcode>;\n capabilities?: StaticDecode<typeof Capabilities>;\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 // TODO: Implement support for other account types.\n if (ci.factoryType !== \"MAv2.0.0-sma-b\") {\n throw new Error(\"Only MAv2 SMA-B accounts are currently supported\");\n }\n\n const parsedContext = parsePermissionsContext(params.capabilities, ci);\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 return createModularAccountV2({\n ...accountParams,\n signerEntity,\n deferredAction: parsedContext?.deferredAction,\n initCode: concatHex([ci.factoryAddress, ci.factoryData]),\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,sBAAsB,GAEvB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAG9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAWvE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA2B;IAE3B,MAAM,EAAE,kBAAkB,EAAE,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC;IAC5D,mDAAmD;IACnD,IAAI,EAAE,CAAC,WAAW,KAAK,gBAAgB,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,aAAa,GAAG,uBAAuB,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAEvE,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,OAAO,sBAAsB,CAAC;QAC5B,GAAG,aAAa;QAChB,YAAY;QACZ,cAAc,EAAE,aAAa,EAAE,cAAc;QAC7C,QAAQ,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;KACzD,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 { Capabilities } from \"../../capabilities/index.js\";\nimport type { TypeSerializedInitcode } from \"../../schemas.js\";\nimport { parsePermissionsContext } from \"./parsePermissionsContext.js\";\n\ntype CreateAccountParams = {\n chain: Chain;\n transport: Transport;\n signer: SmartAccountSigner;\n accountAddress: Address;\n counterfactualInfo: StaticDecode<typeof TypeSerializedInitcode>;\n capabilities?: StaticDecode<typeof Capabilities>;\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 // TODO: Implement support for other account types.\n if (ci.factoryType !== \"MAv2.0.0-sma-b\") {\n throw new Error(\"Only MAv2 SMA-B accounts are currently supported\");\n }\n\n const parsedContext = parsePermissionsContext(params.capabilities, ci);\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 return createModularAccountV2({\n ...accountParams,\n signerEntity,\n deferredAction: parsedContext?.deferredAction,\n initCode: concatHex([ci.factoryAddress, ci.factoryData]),\n });\n}\n\nexport function isModularAccountV2(\n account: SmartContractAccount,\n): account is ModularAccountV2 {\n return account.source === \"ModularAccountV2\";\n}\n"]}
@@ -1,15 +1,15 @@
1
1
  import type { StaticDecode } from "@sinclair/typebox";
2
- import type { PrepareCallsParams } from "../actions/prepareCalls";
3
- import type { TypeSerializedInitcode } from "../../schemas";
2
+ import type { TypeSerializedInitcode } from "../../schemas.js";
3
+ import type { PrepareCallsParams } from "../actions/prepareCalls.js";
4
4
  export declare function parsePermissionsContext(capabilities: PrepareCallsParams["capabilities"], parsedCi: StaticDecode<typeof TypeSerializedInitcode>): ({
5
- contextVersion: keyof typeof import("../../exports/internal").PermissionsContextVersion;
5
+ contextVersion: keyof typeof import("../../exports/internal.js").PermissionsContextVersion;
6
6
  } & {
7
7
  contextVersion: "LOCAL_MODE_DEFERRED_ACTION";
8
8
  deferredAction: import("viem").Hex;
9
9
  sessionId?: never;
10
10
  signature?: never;
11
11
  }) | ({
12
- contextVersion: keyof typeof import("../../exports/internal").PermissionsContextVersion;
12
+ contextVersion: keyof typeof import("../../exports/internal.js").PermissionsContextVersion;
13
13
  } & {
14
14
  contextVersion: "NON_DEFERRED_ACTION";
15
15
  deferredAction?: never;
@@ -1,5 +1,5 @@
1
1
  import { InvalidRequestError } from "ox/RpcResponse";
2
- import { decodePermissionsContext } from "../../capabilities/permissions/mav2";
2
+ import { decodePermissionsContext } from "../../capabilities/permissions/mav2.js";
3
3
  export function parsePermissionsContext(capabilities, parsedCi) {
4
4
  if (!capabilities?.permissions?.context) {
5
5
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"parsePermissionsContext.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/parsePermissionsContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAE/E,MAAM,UAAU,uBAAuB,CACrC,YAAgD,EAChD,QAAqD;IAErD,IAAI,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IACE,YAAY,EAAE,WAAW,EAAE,OAAO;QAClC,QAAQ,CAAC,WAAW,KAAK,gBAAgB,EACzC,CAAC;QACD,MAAM,IAAI,mBAAmB,CAAC;YAC5B,OAAO,EAAE,2DAA2D;SACrE,CAAC,CAAC;IACL,CAAC;IAED,MAAM,OAAO,GAAG,wBAAwB,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAE3E,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 type { PrepareCallsParams } from \"../actions/prepareCalls\";\nimport type { TypeSerializedInitcode } from \"../../schemas\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\nimport { decodePermissionsContext } from \"../../capabilities/permissions/mav2\";\n\nexport function parsePermissionsContext(\n capabilities: PrepareCallsParams[\"capabilities\"],\n parsedCi: StaticDecode<typeof TypeSerializedInitcode>,\n) {\n if (!capabilities?.permissions?.context) {\n return undefined;\n }\n\n if (\n capabilities?.permissions?.context &&\n parsedCi.factoryType !== \"MAv2.0.0-sma-b\"\n ) {\n throw new InvalidRequestError({\n message: \"Permissions are currently only supported by MAv2 accounts\",\n });\n }\n\n const context = decodePermissionsContext(capabilities.permissions.context);\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
+ {"version":3,"file":"parsePermissionsContext.js","sourceRoot":"","sources":["../../../../src/isomorphic/utils/parsePermissionsContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAIlF,MAAM,UAAU,uBAAuB,CACrC,YAAgD,EAChD,QAAqD;IAErD,IAAI,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IACE,YAAY,EAAE,WAAW,EAAE,OAAO;QAClC,QAAQ,CAAC,WAAW,KAAK,gBAAgB,EACzC,CAAC;QACD,MAAM,IAAI,mBAAmB,CAAC;YAC5B,OAAO,EAAE,2DAA2D;SACrE,CAAC,CAAC;IACL,CAAC;IAED,MAAM,OAAO,GAAG,wBAAwB,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAE3E,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 { decodePermissionsContext } from \"../../capabilities/permissions/mav2.js\";\nimport type { TypeSerializedInitcode } from \"../../schemas.js\";\nimport type { PrepareCallsParams } from \"../actions/prepareCalls.js\";\n\nexport function parsePermissionsContext(\n capabilities: PrepareCallsParams[\"capabilities\"],\n parsedCi: StaticDecode<typeof TypeSerializedInitcode>,\n) {\n if (!capabilities?.permissions?.context) {\n return undefined;\n }\n\n if (\n capabilities?.permissions?.context &&\n parsedCi.factoryType !== \"MAv2.0.0-sma-b\"\n ) {\n throw new InvalidRequestError({\n message: \"Permissions are currently only supported by MAv2 accounts\",\n });\n }\n\n const context = decodePermissionsContext(capabilities.permissions.context);\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,10 +1,10 @@
1
1
  import { split } from "@aa-sdk/core";
2
- import { createClient, custom } from "viem";
3
- import { createIsomorphicClient, } from "../isomorphic/client";
4
- import { assertNever } from "../utils";
5
- import { signSignatureRequest } from "../client/actions/signSignatureRequest";
6
- import { encodePermissionsContext, prefixSignatureKeyType, } from "../capabilities/permissions/mav2";
7
2
  import { buildDeferredActionDigest } from "@account-kit/smart-contracts/experimental";
3
+ import { createClient, custom } from "viem";
4
+ import { encodePermissionsContext, prefixSignatureKeyType, } from "../capabilities/permissions/mav2.js";
5
+ import { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
6
+ import { createIsomorphicClient, } from "../isomorphic/client.js";
7
+ import { assertNever } from "../utils.js";
8
8
  const localMethods = [
9
9
  "wallet_prepareCalls",
10
10
  "wallet_sendPreparedCalls",
@@ -17,6 +17,7 @@ export function createLocalClient(params) {
17
17
  transport,
18
18
  chain,
19
19
  policyId,
20
+ useErc7677middleware: false,
20
21
  });
21
22
  const clientMap = {
22
23
  [policyId ?? "default"]: isomorphicClient,
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/local/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAqC,MAAM,MAAM,CAAC;AAE/E,OAAO,EACL,sBAAsB,GAEvB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAEtF,MAAM,YAAY,GAAG;IACnB,qBAAqB;IACrB,0BAA0B;IAC1B,uBAAuB;IACvB,sBAAsB;CACK,CAAC;AAS9B,MAAM,UAAU,iBAAiB,CAC/B,MAA+B;IAE/B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACvD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;QAC9C,SAAS;QACT,KAAK;QACL,QAAQ;KACT,CAAC,CAAC;IAEH,MAAM,SAAS,GAA8D;QAC3E,CAAC,QAAQ,IAAI,SAAS,CAAC,EAAE,gBAAgB;KAC1C,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC;QAC3B,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,YAAY;gBACrB,SAAS,EAAE,MAAM,CAAC;oBAChB,8DAA8D;oBAC9D,KAAK,CAAC,OAAO,CAAC,IAA0C;wBACtD,QAAQ,IAAI,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,OAAO;KACR,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,QAAQ;QACR,GAAG,kBAAkB,CAAC,gBAAgB,CAAC;KACxC,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,kBAAkB,GAAG,CACzB,gBAAkC,EACd,EAAE;IACtB,OAAO;QACL,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACzC,MAAM,EAAE,gBAAgB,EAAE,oCAAoC,EAAE,GAC9D,MAAM,gBAAgB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAE/C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,oBAAoB,CAC9C,MAAM,EACN,gBAAgB,CACjB,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,wBAAwB,CAAC;oBAChC,cAAc,EAAE,4BAA4B;oBAC5C,cAAc,EAAE,yBAAyB,CAAC;wBACxC,oCAAoC;wBACpC,GAAG,EAAE,sBAAsB,CAAC,SAAS,EAAE,WAAW,CAAC;qBACpD,CAAC;iBACH,CAAC;aACH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { split } from \"@aa-sdk/core\";\nimport { createClient, custom, type Address, type JsonRpcAccount } from \"viem\";\nimport type { PrepareCallsParams } from \"../isomorphic/actions/prepareCalls\";\nimport {\n createIsomorphicClient,\n type IsomorphicClient,\n} from \"../isomorphic/client\";\nimport type {\n CreateInnerClientParams,\n InnerClientActions,\n InnerWalletApiClient,\n} from \"../types\";\nimport { assertNever } from \"../utils\";\nimport { signSignatureRequest } from \"../client/actions/signSignatureRequest\";\nimport {\n encodePermissionsContext,\n prefixSignatureKeyType,\n} from \"../capabilities/permissions/mav2\";\nimport { buildDeferredActionDigest } from \"@account-kit/smart-contracts/experimental\";\n\nconst localMethods = [\n \"wallet_prepareCalls\",\n \"wallet_sendPreparedCalls\",\n \"wallet_getCallsStatus\",\n \"wallet_createSession\",\n] as const satisfies string[];\ntype LocalMethod = (typeof localMethods)[number];\n\nexport function createLocalClient<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient<TAccount>;\n\nexport function createLocalClient(\n params: CreateInnerClientParams,\n): InnerWalletApiClient {\n const { chain, transport, policyId, account } = params;\n const isomorphicClient = createIsomorphicClient({\n transport,\n chain,\n policyId,\n });\n\n const clientMap: Record<string, ReturnType<typeof createIsomorphicClient>> = {\n [policyId ?? \"default\"]: isomorphicClient,\n };\n\n const innerTransport = split({\n overrides: [\n {\n methods: localMethods,\n transport: custom({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async request(args: { method: LocalMethod; params: any }) {\n switch (args.method) {\n case \"wallet_prepareCalls\": {\n const params = args.params[0] as PrepareCallsParams;\n const capabilityPolicyId =\n params.capabilities?.paymasterService?.policyId;\n\n if (\n capabilityPolicyId != null &&\n policyId !== capabilityPolicyId &&\n !clientMap[capabilityPolicyId]\n ) {\n clientMap[capabilityPolicyId] = createIsomorphicClient({\n transport,\n chain,\n policyId: capabilityPolicyId,\n });\n }\n\n const client =\n clientMap[capabilityPolicyId ?? policyId ?? \"default\"];\n return client.prepareCalls(params);\n }\n case \"wallet_sendPreparedCalls\":\n return isomorphicClient.sendPreparedCalls(args.params[0]);\n case \"wallet_getCallsStatus\":\n return isomorphicClient.getCallsStatus(args.params[0]);\n case \"wallet_createSession\": {\n return isomorphicClient.createSession(args.params[0]);\n }\n default:\n return assertNever(\n args.method,\n `Unexpected method: ${args.method}`,\n );\n }\n },\n }),\n },\n ],\n fallback: transport,\n });\n\n return createClient({\n transport: innerTransport,\n chain,\n account,\n }).extend(() => ({\n policyId,\n ...innerClientActions(isomorphicClient),\n }));\n}\n\nconst innerClientActions = (\n isomorphicClient: IsomorphicClient,\n): InnerClientActions => {\n return {\n grantPermissions: async (signer, params) => {\n const { signatureRequest, fullPreSignatureDeferredActionDigest } =\n await isomorphicClient.createSession(params);\n\n const { signature } = await signSignatureRequest(\n signer,\n signatureRequest,\n );\n\n return {\n context: encodePermissionsContext({\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\",\n deferredAction: buildDeferredActionDigest({\n fullPreSignatureDeferredActionDigest,\n sig: prefixSignatureKeyType(signature, \"secp256k1\"),\n }),\n }),\n };\n },\n };\n};\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/local/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,EAAqC,MAAM,MAAM,CAAC;AAC/E,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EACL,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,YAAY,GAAG;IACnB,qBAAqB;IACrB,0BAA0B;IAC1B,uBAAuB;IACvB,sBAAsB;CACK,CAAC;AAS9B,MAAM,UAAU,iBAAiB,CAC/B,MAA+B;IAE/B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACvD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;QAC9C,SAAS;QACT,KAAK;QACL,QAAQ;QACR,oBAAoB,EAAE,KAAK;KAC5B,CAAC,CAAC;IAEH,MAAM,SAAS,GAA8D;QAC3E,CAAC,QAAQ,IAAI,SAAS,CAAC,EAAE,gBAAgB;KAC1C,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC;QAC3B,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,YAAY;gBACrB,SAAS,EAAE,MAA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S;KACpB,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;QAClB,SAAS,EAAE,cAAc;QACzB,KAAK;QACL,OAAO;KACR,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,QAAQ;QACR,GAAG,kBAAkB,CAAC,gBAAgB,CAAC;KACxC,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,kBAAkB,GAAG,CACzB,gBAAkC,EACd,EAAE;IACtB,OAAO;QACL,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACzC,MAAM,EAAE,gBAAgB,EAAE,oCAAoC,EAAE,GAC9D,MAAM,gBAAgB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAE/C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,oBAAoB,CAC9C,MAAM,EACN,gBAAgB,CACjB,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,wBAAwB,CAAC;oBAChC,cAAc,EAAE,4BAA4B;oBAC5C,cAAc,EAAE,yBAAyB,CAAC;wBACxC,oCAAoC;wBACpC,GAAG,EAAE,sBAAsB,CAAC,SAAS,EAAE,WAAW,CAAC;qBACpD,CAAC;iBACH,CAAC;aACH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { split } from \"@aa-sdk/core\";\nimport { buildDeferredActionDigest } from \"@account-kit/smart-contracts/experimental\";\nimport { createClient, custom, type Address, type JsonRpcAccount } from \"viem\";\nimport {\n encodePermissionsContext,\n prefixSignatureKeyType,\n} from \"../capabilities/permissions/mav2.js\";\nimport { signSignatureRequest } from \"../client/actions/signSignatureRequest.js\";\nimport type { PrepareCallsParams } from \"../isomorphic/actions/prepareCalls\";\nimport {\n createIsomorphicClient,\n type IsomorphicClient,\n} from \"../isomorphic/client.js\";\nimport type {\n CreateInnerClientParams,\n InnerClientActions,\n InnerWalletApiClient,\n} from \"../types\";\nimport { assertNever } from \"../utils.js\";\n\nconst localMethods = [\n \"wallet_prepareCalls\",\n \"wallet_sendPreparedCalls\",\n \"wallet_getCallsStatus\",\n \"wallet_createSession\",\n] as const satisfies string[];\ntype LocalMethod = (typeof localMethods)[number];\n\nexport function createLocalClient<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient<TAccount>;\n\nexport function createLocalClient(\n params: CreateInnerClientParams,\n): InnerWalletApiClient {\n const { chain, transport, policyId, account } = params;\n const isomorphicClient = createIsomorphicClient({\n transport,\n chain,\n policyId,\n useErc7677middleware: false,\n });\n\n const clientMap: Record<string, ReturnType<typeof createIsomorphicClient>> = {\n [policyId ?? \"default\"]: isomorphicClient,\n };\n\n const innerTransport = split({\n overrides: [\n {\n methods: localMethods,\n transport: custom({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async request(args: { method: LocalMethod; params: any }) {\n switch (args.method) {\n case \"wallet_prepareCalls\": {\n const params = args.params[0] as PrepareCallsParams;\n const capabilityPolicyId =\n params.capabilities?.paymasterService?.policyId;\n\n if (\n capabilityPolicyId != null &&\n policyId !== capabilityPolicyId &&\n !clientMap[capabilityPolicyId]\n ) {\n clientMap[capabilityPolicyId] = createIsomorphicClient({\n transport,\n chain,\n policyId: capabilityPolicyId,\n });\n }\n\n const client =\n clientMap[capabilityPolicyId ?? policyId ?? \"default\"];\n return client.prepareCalls(params);\n }\n case \"wallet_sendPreparedCalls\":\n return isomorphicClient.sendPreparedCalls(args.params[0]);\n case \"wallet_getCallsStatus\":\n return isomorphicClient.getCallsStatus(args.params[0]);\n case \"wallet_createSession\": {\n return isomorphicClient.createSession(args.params[0]);\n }\n default:\n return assertNever(\n args.method,\n `Unexpected method: ${args.method}`,\n );\n }\n },\n }),\n },\n ],\n fallback: transport,\n });\n\n return createClient({\n transport: innerTransport,\n chain,\n account,\n }).extend(() => ({\n policyId,\n ...innerClientActions(isomorphicClient),\n }));\n}\n\nconst innerClientActions = (\n isomorphicClient: IsomorphicClient,\n): InnerClientActions => {\n return {\n grantPermissions: async (signer, params) => {\n const { signatureRequest, fullPreSignatureDeferredActionDigest } =\n await isomorphicClient.createSession(params);\n\n const { signature } = await signSignatureRequest(\n signer,\n signatureRequest,\n );\n\n return {\n context: encodePermissionsContext({\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\",\n deferredAction: buildDeferredActionDigest({\n fullPreSignatureDeferredActionDigest,\n sig: prefixSignatureKeyType(signature, \"secp256k1\"),\n }),\n }),\n };\n },\n };\n};\n"]}
@@ -1,8 +1,8 @@
1
1
  import { Provider } from "ox";
2
2
  import { createClient, custom } from "viem";
3
- import { WalletServerRpcSchema } from "../rpc/schema";
4
- import { signSignatureRequest } from "../client/actions/signSignatureRequest";
5
- import { encodePermissionsContext } from "../capabilities/permissions/mav2";
3
+ import { encodePermissionsContext } from "../capabilities/permissions/mav2.js";
4
+ import { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
5
+ import { WalletServerRpcSchema } from "../rpc/schema.js";
6
6
  /**
7
7
  * This is a low-level client just used to make RPC requests in remote mode
8
8
  * This should be wrapped by a higher-level smart account client that provides actions
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/remote/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,EAAqC,MAAM,MAAM,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAOtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAQ5E;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA+B;IAE/B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAE7C,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC,CACvE,IAAI,CACL;QACH,KAAK;QACL,OAAO;KACR,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,GAAG,kBAAkB,CAAC,OAAO,CAAC;KAC/B,CAAC,CAAC,CAAC;IAEJ,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,kBAAkB,GAAG,CACzB,SAAmC,EACf,EAAE;IACtB,OAAO;QACL,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACzC,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC;gBAC9D,MAAM,EAAE,sBAAsB;gBAC9B,MAAM,EAAE,CAAC,MAAM,CAAC;aACjB,CAAC,CAAC;YACH,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,oBAAoB,CAC9C,MAAM,EACN,gBAAgB,CACjB,CAAC;YACF,OAAO;gBACL,OAAO,EAAE,wBAAwB,CAAC;oBAChC,cAAc,EAAE,6BAA6B;oBAC7C,SAAS;oBACT,SAAS;iBACV,CAAC;aACH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Provider } from \"ox\";\nimport { createClient, custom, type Address, type JsonRpcAccount } from \"viem\";\nimport { WalletServerRpcSchema } from \"../rpc/schema\";\nimport type {\n CreateInnerClientParams,\n InnerClientActions,\n InnerWalletApiClient,\n InnerWalletApiClientBase,\n} from \"../types\";\nimport { signSignatureRequest } from \"../client/actions/signSignatureRequest\";\nimport { encodePermissionsContext } from \"../capabilities/permissions/mav2\";\n\nexport function createRemoteClient<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient<TAccount>;\n\n/**\n * This is a low-level client just used to make RPC requests in remote mode\n * This should be wrapped by a higher-level smart account client that provides actions\n * that uses this client under the hood\n * @returns\n */\nexport function createRemoteClient(\n params: CreateInnerClientParams,\n): InnerWalletApiClient {\n const { transport, chain, account } = params;\n\n const client = createClient({\n transport: (opts) =>\n custom(Provider.from(transport(opts), { schema: WalletServerRpcSchema }))(\n opts,\n ),\n chain,\n account,\n }).extend((_client) => ({\n policyId: params.policyId,\n ...innerClientActions(_client),\n }));\n\n return client;\n}\n\nconst innerClientActions = (\n apiClient: InnerWalletApiClientBase,\n): InnerClientActions => {\n return {\n grantPermissions: async (signer, params) => {\n const { sessionId, signatureRequest } = await apiClient.request({\n method: \"wallet_createSession\",\n params: [params],\n });\n const { signature } = await signSignatureRequest(\n signer,\n signatureRequest,\n );\n return {\n context: encodePermissionsContext({\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId,\n signature,\n }),\n };\n },\n };\n};\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/remote/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,EAAqC,MAAM,MAAM,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAczD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA+B;IAE/B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAE7C,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC,CACvE,IAAI,CACL;QACH,KAAK;QACL,OAAO;KACR,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,GAAG,kBAAkB,CAAC,OAAO,CAAC;KAC/B,CAAC,CAAC,CAAC;IAEJ,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,kBAAkB,GAAG,CACzB,SAAmC,EACf,EAAE;IACtB,OAAO;QACL,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACzC,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC;gBAC9D,MAAM,EAAE,sBAAsB;gBAC9B,MAAM,EAAE,CAAC,MAAM,CAAC;aACjB,CAAC,CAAC;YACH,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,oBAAoB,CAC9C,MAAM,EACN,gBAAgB,CACjB,CAAC;YACF,OAAO;gBACL,OAAO,EAAE,wBAAwB,CAAC;oBAChC,cAAc,EAAE,6BAA6B;oBAC7C,SAAS;oBACT,SAAS;iBACV,CAAC;aACH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Provider } from \"ox\";\nimport { createClient, custom, type Address, type JsonRpcAccount } from \"viem\";\nimport { encodePermissionsContext } from \"../capabilities/permissions/mav2.js\";\nimport { signSignatureRequest } from \"../client/actions/signSignatureRequest.js\";\nimport { WalletServerRpcSchema } from \"../rpc/schema.js\";\nimport type {\n CreateInnerClientParams,\n InnerClientActions,\n InnerWalletApiClient,\n InnerWalletApiClientBase,\n} from \"../types\";\n\nexport function createRemoteClient<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient<TAccount>;\n\n/**\n * This is a low-level client just used to make RPC requests in remote mode\n * This should be wrapped by a higher-level smart account client that provides actions\n * that uses this client under the hood\n * @returns\n */\nexport function createRemoteClient(\n params: CreateInnerClientParams,\n): InnerWalletApiClient {\n const { transport, chain, account } = params;\n\n const client = createClient({\n transport: (opts) =>\n custom(Provider.from(transport(opts), { schema: WalletServerRpcSchema }))(\n opts,\n ),\n chain,\n account,\n }).extend((_client) => ({\n policyId: params.policyId,\n ...innerClientActions(_client),\n }));\n\n return client;\n}\n\nconst innerClientActions = (\n apiClient: InnerWalletApiClientBase,\n): InnerClientActions => {\n return {\n grantPermissions: async (signer, params) => {\n const { sessionId, signatureRequest } = await apiClient.request({\n method: \"wallet_createSession\",\n params: [params],\n });\n const { signature } = await signSignatureRequest(\n signer,\n signatureRequest,\n );\n return {\n context: encodePermissionsContext({\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId,\n signature,\n }),\n };\n },\n };\n};\n"]}
@@ -32,7 +32,7 @@ export declare const wallet_sendPreparedCalls: import("@sinclair/typebox").TObje
32
32
  }>]>;
33
33
  chainId: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
34
34
  signature: import("@sinclair/typebox").TObject<{
35
- type: import("@sinclair/typebox").TString;
35
+ type: import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, "ecdsa">;
36
36
  signature: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
37
37
  }>;
38
38
  capabilities: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
@@ -64,6 +64,29 @@ export declare const wallet_prepareCalls: import("@sinclair/typebox").TObject<{
64
64
  paymasterService: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
65
65
  policyId: import("@sinclair/typebox").TString;
66
66
  }>>;
67
+ gasParamsOverride: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
68
+ preVerificationGas: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">, import("@sinclair/typebox").TObject<{
69
+ multiplier: import("@sinclair/typebox").TNumber;
70
+ }>]>>;
71
+ verificationGasLimit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">, import("@sinclair/typebox").TObject<{
72
+ multiplier: import("@sinclair/typebox").TNumber;
73
+ }>]>>;
74
+ callGasLimit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">, import("@sinclair/typebox").TObject<{
75
+ multiplier: import("@sinclair/typebox").TNumber;
76
+ }>]>>;
77
+ paymasterVerificationGasLimit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">, import("@sinclair/typebox").TObject<{
78
+ multiplier: import("@sinclair/typebox").TNumber;
79
+ }>]>>;
80
+ paymasterPostOpGasLimit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">, import("@sinclair/typebox").TObject<{
81
+ multiplier: import("@sinclair/typebox").TNumber;
82
+ }>]>>;
83
+ maxFeePerGas: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">, import("@sinclair/typebox").TObject<{
84
+ multiplier: import("@sinclair/typebox").TNumber;
85
+ }>]>>;
86
+ maxPriorityFeePerGas: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">, import("@sinclair/typebox").TObject<{
87
+ multiplier: import("@sinclair/typebox").TNumber;
88
+ }>]>>;
89
+ }>>;
67
90
  }>>;
68
91
  }>]>;
69
92
  }>;
@@ -214,44 +237,44 @@ export declare const wallet_createSession: import("@sinclair/typebox").TObject<{
214
237
  publicKey: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
215
238
  }>;
216
239
  permissions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
217
- type: import("@sinclair/typebox").TLiteral<import("@account-kit/smart-contracts/experimental").PermissionType.NATIVE_TOKEN_TRANSFER>;
240
+ type: import("@sinclair/typebox").TLiteral<"native-token-transfer">;
218
241
  data: import("@sinclair/typebox").TObject<{
219
242
  allowance: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
220
243
  }>;
221
244
  }>, import("@sinclair/typebox").TObject<{
222
- type: import("@sinclair/typebox").TLiteral<import("@account-kit/smart-contracts/experimental").PermissionType.ERC20_TOKEN_TRANSFER>;
245
+ type: import("@sinclair/typebox").TLiteral<"erc20-token-transfer">;
223
246
  data: import("@sinclair/typebox").TObject<{
224
247
  allowance: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
225
248
  address: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
226
249
  }>;
227
250
  }>, import("@sinclair/typebox").TObject<{
228
- type: import("@sinclair/typebox").TLiteral<import("@account-kit/smart-contracts/experimental").PermissionType.GAS_LIMIT>;
251
+ type: import("@sinclair/typebox").TLiteral<"gas-limit">;
229
252
  data: import("@sinclair/typebox").TObject<{
230
253
  limit: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
231
254
  }>;
232
255
  }>, import("@sinclair/typebox").TObject<{
233
- type: import("@sinclair/typebox").TLiteral<import("@account-kit/smart-contracts/experimental").PermissionType.CONTRACT_ACCESS>;
256
+ type: import("@sinclair/typebox").TLiteral<"contract-access">;
234
257
  data: import("@sinclair/typebox").TObject<{
235
258
  address: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
236
259
  }>;
237
260
  }>, import("@sinclair/typebox").TObject<{
238
- type: import("@sinclair/typebox").TLiteral<import("@account-kit/smart-contracts/experimental").PermissionType.ACCOUNT_FUNCTIONS>;
261
+ type: import("@sinclair/typebox").TLiteral<"account-functions">;
239
262
  data: import("@sinclair/typebox").TObject<{
240
263
  functions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">>;
241
264
  }>;
242
265
  }>, import("@sinclair/typebox").TObject<{
243
- type: import("@sinclair/typebox").TLiteral<import("@account-kit/smart-contracts/experimental").PermissionType.FUNCTIONS_ON_ALL_CONTRACTS>;
266
+ type: import("@sinclair/typebox").TLiteral<"functions-on-all-contracts">;
244
267
  data: import("@sinclair/typebox").TObject<{
245
268
  functions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">>;
246
269
  }>;
247
270
  }>, import("@sinclair/typebox").TObject<{
248
- type: import("@sinclair/typebox").TLiteral<import("@account-kit/smart-contracts/experimental").PermissionType.FUNCTIONS_ON_CONTRACT>;
271
+ type: import("@sinclair/typebox").TLiteral<"functions-on-contract">;
249
272
  data: import("@sinclair/typebox").TObject<{
250
273
  address: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
251
274
  functions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">>;
252
275
  }>;
253
276
  }>, import("@sinclair/typebox").TObject<{
254
- type: import("@sinclair/typebox").TLiteral<import("@account-kit/smart-contracts/experimental").PermissionType.ROOT>;
277
+ type: import("@sinclair/typebox").TLiteral<"root">;
255
278
  data: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNever>;
256
279
  }>]>>;
257
280
  }>, import("@sinclair/typebox").TObject<{
@@ -1,7 +1,7 @@
1
1
  import { Type } from "@sinclair/typebox";
2
- import { Capabilities } from "../capabilities";
3
- import { PermissionsContext, PermissionsData, } from "../capabilities/permissions";
4
- import { TypeAddress, TypeBase64UrlEncodedString, TypeCreationOptions, TypeHex, TypeSerializedInitcode, TypeSignatureRequest, TypeUserOperationRequest_v6, TypeUserOperationRequest_v7, TypeUuid, } from "../schemas";
2
+ import { Capabilities } from "../capabilities/index.js";
3
+ import { PermissionsContext, PermissionsData, } from "../capabilities/permissions/index.js";
4
+ import { TypeAddress, TypeBase64UrlEncodedString, TypeCreationOptions, TypeHex, TypeSerializedInitcode, TypeSignatureRequest, TypeUserOperationRequest_v6, TypeUserOperationRequest_v7, TypeUuid, } from "../schemas.js";
5
5
  export const wallet_sendPreparedCalls = Type.Object({
6
6
  Request: Type.Object({
7
7
  method: Type.Literal("wallet_sendPreparedCalls"),
@@ -17,9 +17,14 @@ export const wallet_sendPreparedCalls = Type.Object({
17
17
  ]),
18
18
  chainId: TypeHex(),
19
19
  signature: Type.Object({
20
- // ignored, but in the spec can be used when the signature on the UO needs to be formatted differently
21
- // potentially useful for deferred actions?
22
- type: Type.String(),
20
+ type: Type.Transform(Type.String())
21
+ .Decode((value) => {
22
+ if (value.toLowerCase() !== "ecdsa") {
23
+ throw new Error("Invalid signature type, must be 'ecdsa'");
24
+ }
25
+ return "ecdsa";
26
+ })
27
+ .Encode((value) => value),
23
28
  signature: TypeHex(),
24
29
  }),
25
30
  capabilities: Type.Optional(Type.Object({ permissions: PermissionsContext })),
@@ -135,13 +140,18 @@ export const wallet_createSession = Type.Object({
135
140
  Request: Type.Object({
136
141
  method: Type.Literal("wallet_createSession"),
137
142
  params: Type.Tuple([
138
- Type.Intersect([PermissionsData, Type.Object({ account: TypeAddress })]),
143
+ Type.Intersect([
144
+ PermissionsData,
145
+ Type.Object({ account: TypeAddress }),
146
+ ]),
139
147
  ]),
140
148
  }),
141
149
  ReturnType: Type.Object({
142
150
  sessionId: TypeHex(),
143
151
  signatureRequest: TypeSignatureRequest,
144
152
  }),
153
+ }, {
154
+ description: "This method is used to create a session for a given address with specified permissions.",
145
155
  });
146
156
  export const wallet_getCallsStatus = Type.Object({
147
157
  Request: Type.Object({