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

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 (188) hide show
  1. package/dist/esm/capabilities/index.d.ts +5 -2
  2. package/dist/esm/capabilities/index.js +1 -1
  3. package/dist/esm/capabilities/index.js.map +1 -1
  4. package/dist/esm/capabilities/overrides.js +8 -8
  5. package/dist/esm/capabilities/overrides.js.map +1 -1
  6. package/dist/esm/capabilities/permissions/index.d.ts +10 -3
  7. package/dist/esm/capabilities/permissions/index.js +11 -2
  8. package/dist/esm/capabilities/permissions/index.js.map +1 -1
  9. package/dist/esm/capabilities/permissions/mav2.d.ts +3 -3
  10. package/dist/esm/capabilities/permissions/mav2.js +9 -1
  11. package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
  12. package/dist/esm/client/actions/createAccount.d.ts +27 -2
  13. package/dist/esm/client/actions/createAccount.js +25 -0
  14. package/dist/esm/client/actions/createAccount.js.map +1 -1
  15. package/dist/esm/client/actions/getCallsStatus.d.ts +21 -2
  16. package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
  17. package/dist/esm/client/actions/grantPermissions.d.ts +114 -2
  18. package/dist/esm/client/actions/grantPermissions.js +1 -0
  19. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  20. package/dist/esm/client/actions/listAccounts.d.ts +26 -2
  21. package/dist/esm/client/actions/listAccounts.js +24 -0
  22. package/dist/esm/client/actions/listAccounts.js.map +1 -1
  23. package/dist/esm/client/actions/prepareCalls.d.ts +28 -2
  24. package/dist/esm/client/actions/prepareCalls.js.map +1 -1
  25. package/dist/esm/client/actions/requestAccount.d.ts +21 -2
  26. package/dist/esm/client/actions/requestAccount.js +15 -4
  27. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  28. package/dist/esm/client/actions/sendPreparedCalls.d.ts +39 -2
  29. package/dist/esm/client/actions/sendPreparedCalls.js +37 -0
  30. package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
  31. package/dist/esm/client/actions/signMessage.d.ts +22 -2
  32. package/dist/esm/client/actions/signMessage.js +4 -2
  33. package/dist/esm/client/actions/signMessage.js.map +1 -1
  34. package/dist/esm/client/actions/signSignatureRequest.d.ts +34 -0
  35. package/dist/esm/client/actions/signSignatureRequest.js +22 -1
  36. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  37. package/dist/esm/client/actions/signTypedData.d.ts +35 -2
  38. package/dist/esm/client/actions/signTypedData.js +3 -1
  39. package/dist/esm/client/actions/signTypedData.js.map +1 -1
  40. package/dist/esm/client/client.e2e-test.js +112 -30
  41. package/dist/esm/client/client.e2e-test.js.map +1 -1
  42. package/dist/esm/client/decorator.d.ts +7 -5
  43. package/dist/esm/client/decorator.js +1 -1
  44. package/dist/esm/client/decorator.js.map +1 -1
  45. package/dist/esm/client/index.d.ts +4 -4
  46. package/dist/esm/client/index.js +29 -3
  47. package/dist/esm/client/index.js.map +1 -1
  48. package/dist/esm/exports/index.d.ts +1 -0
  49. package/dist/esm/exports/index.js +1 -0
  50. package/dist/esm/exports/index.js.map +1 -1
  51. package/dist/esm/exports/internal.d.ts +1 -1
  52. package/dist/esm/exports/internal.js.map +1 -1
  53. package/dist/esm/internal/decorator.d.ts +2 -0
  54. package/dist/esm/internal/decorator.js +10 -0
  55. package/dist/esm/internal/decorator.js.map +1 -0
  56. package/dist/esm/isomorphic/actions/createSession.js +25 -7
  57. package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
  58. package/dist/esm/isomorphic/actions/prepareCalls.js +35 -12
  59. package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
  60. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +26 -6
  61. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
  62. package/dist/esm/isomorphic/client.d.ts +11 -5
  63. package/dist/esm/isomorphic/utils/7702.d.ts +11 -0
  64. package/dist/esm/isomorphic/utils/7702.js +26 -0
  65. package/dist/esm/isomorphic/utils/7702.js.map +1 -0
  66. package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -1
  67. package/dist/esm/isomorphic/utils/createAccount.js +30 -5
  68. package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
  69. package/dist/esm/isomorphic/utils/createDummySigner.js +3 -3
  70. package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -1
  71. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +2 -1
  72. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +17 -5
  73. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
  74. package/dist/esm/local/client.d.ts +1 -1
  75. package/dist/esm/local/client.js +10 -2
  76. package/dist/esm/local/client.js.map +1 -1
  77. package/dist/esm/remote/client.d.ts +1 -1
  78. package/dist/esm/remote/client.js +12 -3
  79. package/dist/esm/remote/client.js.map +1 -1
  80. package/dist/esm/rpc/examples.d.ts +230 -0
  81. package/dist/esm/rpc/examples.js +314 -0
  82. package/dist/esm/rpc/examples.js.map +1 -0
  83. package/dist/esm/rpc/request.d.ts +48 -17
  84. package/dist/esm/rpc/request.js +53 -14
  85. package/dist/esm/rpc/request.js.map +1 -1
  86. package/dist/esm/rpc/schema.d.ts +43 -12
  87. package/dist/esm/schemas.d.ts +29 -7
  88. package/dist/esm/schemas.js +120 -38
  89. package/dist/esm/schemas.js.map +1 -1
  90. package/dist/esm/types.d.ts +15 -4
  91. package/dist/esm/types.js.map +1 -1
  92. package/dist/types/capabilities/index.d.ts +5 -2
  93. package/dist/types/capabilities/index.d.ts.map +1 -1
  94. package/dist/types/capabilities/overrides.d.ts.map +1 -1
  95. package/dist/types/capabilities/permissions/index.d.ts +10 -3
  96. package/dist/types/capabilities/permissions/index.d.ts.map +1 -1
  97. package/dist/types/capabilities/permissions/mav2.d.ts +3 -3
  98. package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -1
  99. package/dist/types/client/actions/createAccount.d.ts +27 -2
  100. package/dist/types/client/actions/createAccount.d.ts.map +1 -1
  101. package/dist/types/client/actions/getCallsStatus.d.ts +21 -2
  102. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  103. package/dist/types/client/actions/grantPermissions.d.ts +114 -2
  104. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  105. package/dist/types/client/actions/listAccounts.d.ts +26 -2
  106. package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
  107. package/dist/types/client/actions/prepareCalls.d.ts +28 -2
  108. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  109. package/dist/types/client/actions/requestAccount.d.ts +21 -2
  110. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  111. package/dist/types/client/actions/sendPreparedCalls.d.ts +39 -2
  112. package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
  113. package/dist/types/client/actions/signMessage.d.ts +22 -2
  114. package/dist/types/client/actions/signMessage.d.ts.map +1 -1
  115. package/dist/types/client/actions/signSignatureRequest.d.ts +34 -0
  116. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  117. package/dist/types/client/actions/signTypedData.d.ts +35 -2
  118. package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
  119. package/dist/types/client/decorator.d.ts +7 -5
  120. package/dist/types/client/decorator.d.ts.map +1 -1
  121. package/dist/types/client/index.d.ts +4 -4
  122. package/dist/types/client/index.d.ts.map +1 -1
  123. package/dist/types/exports/index.d.ts +1 -0
  124. package/dist/types/exports/index.d.ts.map +1 -1
  125. package/dist/types/exports/internal.d.ts +1 -1
  126. package/dist/types/exports/internal.d.ts.map +1 -1
  127. package/dist/types/internal/decorator.d.ts +3 -0
  128. package/dist/types/internal/decorator.d.ts.map +1 -0
  129. package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
  130. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
  131. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
  132. package/dist/types/isomorphic/client.d.ts +11 -5
  133. package/dist/types/isomorphic/client.d.ts.map +1 -1
  134. package/dist/types/isomorphic/utils/7702.d.ts +12 -0
  135. package/dist/types/isomorphic/utils/7702.d.ts.map +1 -0
  136. package/dist/types/isomorphic/utils/createAccount.d.ts +2 -1
  137. package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
  138. package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +1 -1
  139. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +2 -1
  140. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
  141. package/dist/types/local/client.d.ts +1 -1
  142. package/dist/types/local/client.d.ts.map +1 -1
  143. package/dist/types/remote/client.d.ts +1 -1
  144. package/dist/types/remote/client.d.ts.map +1 -1
  145. package/dist/types/rpc/examples.d.ts +231 -0
  146. package/dist/types/rpc/examples.d.ts.map +1 -0
  147. package/dist/types/rpc/request.d.ts +48 -17
  148. package/dist/types/rpc/request.d.ts.map +1 -1
  149. package/dist/types/rpc/schema.d.ts +43 -12
  150. package/dist/types/rpc/schema.d.ts.map +1 -1
  151. package/dist/types/schemas.d.ts +29 -7
  152. package/dist/types/schemas.d.ts.map +1 -1
  153. package/dist/types/types.d.ts +15 -4
  154. package/dist/types/types.d.ts.map +1 -1
  155. package/package.json +8 -6
  156. package/src/capabilities/index.ts +5 -8
  157. package/src/capabilities/overrides.ts +23 -8
  158. package/src/capabilities/permissions/index.ts +21 -5
  159. package/src/capabilities/permissions/mav2.ts +13 -3
  160. package/src/client/actions/createAccount.ts +27 -2
  161. package/src/client/actions/getCallsStatus.ts +21 -2
  162. package/src/client/actions/grantPermissions.ts +114 -2
  163. package/src/client/actions/listAccounts.ts +26 -2
  164. package/src/client/actions/prepareCalls.ts +28 -2
  165. package/src/client/actions/requestAccount.ts +41 -7
  166. package/src/client/actions/sendPreparedCalls.ts +39 -2
  167. package/src/client/actions/signMessage.ts +24 -4
  168. package/src/client/actions/signSignatureRequest.ts +61 -2
  169. package/src/client/actions/signTypedData.ts +39 -3
  170. package/src/client/client.e2e-test.ts +134 -32
  171. package/src/client/decorator.ts +10 -12
  172. package/src/client/index.ts +41 -10
  173. package/src/exports/index.ts +1 -0
  174. package/src/exports/internal.ts +1 -1
  175. package/src/internal/decorator.ts +12 -0
  176. package/src/isomorphic/actions/createSession.ts +28 -7
  177. package/src/isomorphic/actions/prepareCalls.ts +38 -11
  178. package/src/isomorphic/actions/sendPreparedCalls.ts +47 -20
  179. package/src/isomorphic/utils/7702.ts +58 -0
  180. package/src/isomorphic/utils/createAccount.ts +38 -6
  181. package/src/isomorphic/utils/createDummySigner.ts +3 -2
  182. package/src/isomorphic/utils/parsePermissionsContext.ts +23 -7
  183. package/src/local/client.ts +54 -45
  184. package/src/remote/client.ts +22 -7
  185. package/src/rpc/examples.ts +343 -0
  186. package/src/rpc/request.ts +75 -26
  187. package/src/schemas.ts +218 -87
  188. package/src/types.ts +18 -4
@@ -1,7 +1,10 @@
1
1
  export declare const Capabilities: import("@sinclair/typebox").TObject<{
2
- permissions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
2
+ permissions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
3
3
  context: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
4
- }>>;
4
+ }>, import("@sinclair/typebox").TObject<{
5
+ sessionId: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
6
+ signature: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
7
+ }>]>>;
5
8
  paymasterService: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
6
9
  policyId: import("@sinclair/typebox").TString;
7
10
  }>>;
@@ -6,5 +6,5 @@ export const Capabilities = Type.Object({
6
6
  permissions: Type.Optional(PermissionsCapability),
7
7
  paymasterService: Type.Optional(PaymasterCapability),
8
8
  gasParamsOverride: Type.Optional(GasParamsOverrideCapability),
9
- }, { minProperties: 1 });
9
+ });
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/capabilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CACrC;IACE,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACjD,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IACpD,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC;CAC9D,EACD,EAAE,aAAa,EAAE,CAAC,EAAE,CACrB,CAAC","sourcesContent":["import { Type } from \"@sinclair/typebox\";\nimport { GasParamsOverrideCapability } from \"./overrides.js\";\nimport { PaymasterCapability } from \"./paymaster.js\";\nimport { PermissionsCapability } from \"./permissions/index.js\";\n\nexport const Capabilities = Type.Object(\n {\n permissions: Type.Optional(PermissionsCapability),\n paymasterService: Type.Optional(PaymasterCapability),\n gasParamsOverride: Type.Optional(GasParamsOverrideCapability),\n },\n { minProperties: 1 },\n);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/capabilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IACtC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACjD,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IACpD,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC;CAC9D,CAAC,CAAC","sourcesContent":["import { Type } from \"@sinclair/typebox\";\nimport { GasParamsOverrideCapability } from \"./overrides.js\";\nimport { PaymasterCapability } from \"./paymaster.js\";\nimport { PermissionsCapability } from \"./permissions/index.js\";\n\nexport const Capabilities = Type.Object({\n permissions: Type.Optional(PermissionsCapability),\n paymasterService: Type.Optional(PaymasterCapability),\n gasParamsOverride: Type.Optional(GasParamsOverrideCapability),\n});\n"]}
@@ -1,14 +1,14 @@
1
1
  import { Type } from "@sinclair/typebox";
2
2
  import { TypeHex } from "../schemas.js";
3
- export const Mutliplier = Type.Object({ multiplier: Type.Number() });
3
+ export const Mutliplier = Type.Object({ multiplier: Type.Number() }, { title: "Multiplier" });
4
4
  // This is still being defined in https://github.com/ethereum/ERCs/pull/947/files#diff-dab085f963ca621595044bcbc0922705aa38b69f5bf8770dcb3d0496a633efcfR158
5
5
  export const GasParamsOverrideCapability = Type.Object({
6
- preVerificationGas: Type.Optional(Type.Union([TypeHex(), Mutliplier])),
7
- verificationGasLimit: Type.Optional(Type.Union([TypeHex(), Mutliplier])),
8
- callGasLimit: Type.Optional(Type.Union([TypeHex(), Mutliplier])),
9
- paymasterVerificationGasLimit: Type.Optional(Type.Union([TypeHex(), Mutliplier])),
10
- paymasterPostOpGasLimit: Type.Optional(Type.Union([TypeHex(), Mutliplier])),
11
- maxFeePerGas: Type.Optional(Type.Union([TypeHex(), Mutliplier])),
12
- maxPriorityFeePerGas: Type.Optional(Type.Union([TypeHex(), Mutliplier])),
6
+ preVerificationGas: Type.Optional(Type.Union([TypeHex({ title: "Absolute" }), Mutliplier])),
7
+ verificationGasLimit: Type.Optional(Type.Union([TypeHex({ title: "Absolute" }), Mutliplier])),
8
+ callGasLimit: Type.Optional(Type.Union([TypeHex({ title: "Absolute" }), Mutliplier])),
9
+ paymasterVerificationGasLimit: Type.Optional(Type.Union([TypeHex({ title: "Absolute" }), Mutliplier])),
10
+ paymasterPostOpGasLimit: Type.Optional(Type.Union([TypeHex({ title: "Absolute" }), Mutliplier])),
11
+ maxFeePerGas: Type.Optional(Type.Union([TypeHex({ title: "Absolute" }), Mutliplier])),
12
+ maxPriorityFeePerGas: Type.Optional(Type.Union([TypeHex({ title: "Absolute" }), Mutliplier])),
13
13
  }, { minProperties: 1 });
14
14
  //# sourceMappingURL=overrides.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../../src/capabilities/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAErE,2JAA2J;AAC3J,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC,MAAM,CACpD;IACE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;IACtE,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;IACxE,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;IAChE,6BAA6B,EAAE,IAAI,CAAC,QAAQ,CAC1C,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC,CACpC;IACD,uBAAuB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3E,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;IAChE,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;CACzE,EACD,EAAE,aAAa,EAAE,CAAC,EAAE,CACrB,CAAC","sourcesContent":["import { Type } from \"@sinclair/typebox\";\nimport { TypeHex } from \"../schemas.js\";\n\nexport const Mutliplier = Type.Object({ multiplier: Type.Number() });\n\n// This is still being defined in https://github.com/ethereum/ERCs/pull/947/files#diff-dab085f963ca621595044bcbc0922705aa38b69f5bf8770dcb3d0496a633efcfR158\nexport const GasParamsOverrideCapability = Type.Object(\n {\n preVerificationGas: Type.Optional(Type.Union([TypeHex(), Mutliplier])),\n verificationGasLimit: Type.Optional(Type.Union([TypeHex(), Mutliplier])),\n callGasLimit: Type.Optional(Type.Union([TypeHex(), Mutliplier])),\n paymasterVerificationGasLimit: Type.Optional(\n Type.Union([TypeHex(), Mutliplier]),\n ),\n paymasterPostOpGasLimit: Type.Optional(Type.Union([TypeHex(), Mutliplier])),\n maxFeePerGas: Type.Optional(Type.Union([TypeHex(), Mutliplier])),\n maxPriorityFeePerGas: Type.Optional(Type.Union([TypeHex(), Mutliplier])),\n },\n { minProperties: 1 },\n);\n"]}
1
+ {"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../../src/capabilities/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CACn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,CAAC,CACzD;CACF,EACD,EAAE,aAAa,EAAE,CAAC,EAAE,CACrB,CAAC","sourcesContent":["import { Type } from \"@sinclair/typebox\";\nimport { TypeHex } from \"../schemas.js\";\n\nexport const Mutliplier = Type.Object(\n { multiplier: Type.Number() },\n { title: \"Multiplier\" },\n);\n\n// This is still being defined in https://github.com/ethereum/ERCs/pull/947/files#diff-dab085f963ca621595044bcbc0922705aa38b69f5bf8770dcb3d0496a633efcfR158\nexport const GasParamsOverrideCapability = Type.Object(\n {\n preVerificationGas: Type.Optional(\n Type.Union([TypeHex({ title: \"Absolute\" }), Mutliplier]),\n ),\n verificationGasLimit: Type.Optional(\n Type.Union([TypeHex({ title: \"Absolute\" }), Mutliplier]),\n ),\n callGasLimit: Type.Optional(\n Type.Union([TypeHex({ title: \"Absolute\" }), Mutliplier]),\n ),\n paymasterVerificationGasLimit: Type.Optional(\n Type.Union([TypeHex({ title: \"Absolute\" }), Mutliplier]),\n ),\n paymasterPostOpGasLimit: Type.Optional(\n Type.Union([TypeHex({ title: \"Absolute\" }), Mutliplier]),\n ),\n maxFeePerGas: Type.Optional(\n Type.Union([TypeHex({ title: \"Absolute\" }), Mutliplier]),\n ),\n maxPriorityFeePerGas: Type.Optional(\n Type.Union([TypeHex({ title: \"Absolute\" }), Mutliplier]),\n ),\n },\n { minProperties: 1 },\n);\n"]}
@@ -84,9 +84,13 @@ export declare const PermissionsArray: import("@sinclair/typebox").TArray<import
84
84
  export declare const PermissionsContext: TObject<{
85
85
  context: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
86
86
  }>;
87
+ export declare const RemotePermission: TObject<{
88
+ sessionId: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
89
+ signature: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
90
+ }>;
87
91
  export declare const PermissionsData: TObject<{
88
92
  chainId: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
89
- expiry: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
93
+ expiry: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
90
94
  key: TObject<{
91
95
  type: import("@sinclair/typebox").TUnion<[TLiteral<"secp256k1">, TLiteral<"contract">]>;
92
96
  publicKey: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
@@ -133,6 +137,9 @@ export declare const PermissionsData: TObject<{
133
137
  data: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNever>;
134
138
  }>]>>;
135
139
  }>;
136
- export declare const PermissionsCapability: TObject<{
140
+ export declare const PermissionsCapability: import("@sinclair/typebox").TUnion<[TObject<{
137
141
  context: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
138
- }>;
142
+ }>, TObject<{
143
+ sessionId: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
144
+ signature: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
145
+ }>]>;
@@ -7,7 +7,7 @@ data, description) => {
7
7
  return Type.Transform(Type.Object({
8
8
  type: Type.Literal(typeEnum),
9
9
  data,
10
- }, { description }))
10
+ }, { description, title: `${typeString}` }))
11
11
  .Decode((value) => ({
12
12
  ...value,
13
13
  type: typeString, // enum → string
@@ -56,15 +56,24 @@ export const TypePermission = Type.Union([
56
56
  export const PermissionsArray = Type.Array(TypePermission, { minItems: 1 });
57
57
  export const PermissionsContext = Type.Object({
58
58
  context: TypeHex(),
59
+ }, {
60
+ title: "Permissions context",
61
+ });
62
+ export const RemotePermission = Type.Object({
63
+ sessionId: TypeHex(),
64
+ signature: TypeHex(),
65
+ }, {
66
+ title: "Remote permission",
59
67
  });
60
68
  export const PermissionsData = Type.Object({
61
69
  chainId: TypeHex(),
62
- expiry: Type.Optional(Type.Number()),
70
+ expiry: Type.Optional(Type.Integer()),
63
71
  key: KeySigner,
64
72
  permissions: PermissionsArray,
65
73
  });
66
74
  export const PermissionsCapability = Type.Union([
67
75
  PermissionsContext,
76
+ RemotePermission,
68
77
  // TODO: support permissions object here instead of only context-encoded permissions
69
78
  // PermissionsData,
70
79
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACL,IAAI,GAKL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEnE,MAAM,UAAU,GAAG,CAKjB,UAAuB,EAAE,eAAe;AACxC,QAAqB,EAAE,4BAA4B;AACnD,IAAW,EACX,WAAmB,EACoB,EAAE;IACzC,OAAO,IAAI,CAAC,SAAS,CACnB,IAAI,CAAC,MAAM,CACT;QACE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC5B,IAAI;KACL,EACD,EAAE,WAAW,EAAE,CAChB,CACF;SACE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClB,GAAG,KAAK;QACR,IAAI,EAAE,UAAU,EAAE,gBAAgB;KACnC,CAAC,CAAC;SACF,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClB,GAAG,KAAK;QACR,IAAI,EAAE,QAAQ,EAAE,gBAAgB;KACjC,CAAC,CAAU,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,UAAU,CACpC,uBAAuB,EACvB,cAAc,CAAC,qBAAqB,EACpC,IAAI,CAAC,MAAM,CAAC;IACV,SAAS,EAAE,OAAO,EAAE;CACrB,CAAC,EACF,mDAAmD,CACpD,CAAC;AAEF,MAAM,kBAAkB,GAAG,UAAU,CACnC,sBAAsB,EACtB,cAAc,CAAC,oBAAoB,EACnC,IAAI,CAAC,MAAM,CAAC;IACV,SAAS,EAAE,OAAO,EAAE;IACpB,OAAO,EAAE,WAAW;CACrB,CAAC,EACF,8DAA8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;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC;IACvC,mBAAmB;IACnB,mBAAmB;IACnB,kBAAkB;IAClB,QAAQ;IACR,yBAAyB;IACzB,cAAc;IACd,eAAe;IACf,yBAAyB;IACzB,sBAAsB;IACtB,IAAI;CACL,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;AAE5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,OAAO,EAAE;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,OAAO,EAAE;IAClB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACpC,GAAG,EAAE,SAAS;IACd,WAAW,EAAE,gBAAgB;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC;IAC9C,kBAAkB;IAClB,oFAAoF;IACpF,mBAAmB;CACpB,CAAC,CAAC","sourcesContent":["import { PermissionType } from \"@account-kit/smart-contracts/experimental\";\nimport {\n Type,\n type TLiteral,\n type TLiteralValue,\n type TObject,\n type TSchema,\n} from \"@sinclair/typebox\";\nimport { KeySigner, TypeAddress, TypeHex } from \"../../schemas.js\";\n\nconst Permission = <\n TData extends TSchema,\n TLiteralVal extends TLiteralValue,\n TType extends TLiteral<TLiteralVal>,\n>(\n typeString: TLiteralVal, // e.g., \"root\"\n typeEnum: TLiteralVal, // e.g., PermissionType.ROOT\n data: TData,\n description: string,\n): TObject<{ type: TType; data: TData }> => {\n return Type.Transform(\n Type.Object(\n {\n type: Type.Literal(typeEnum),\n data,\n },\n { description },\n ),\n )\n .Decode((value) => ({\n ...value,\n type: typeString, // enum → string\n }))\n .Encode((value) => ({\n ...value,\n type: typeEnum, // string → enum\n })) as never;\n};\n\nconst NativeTokenTransfer = Permission(\n \"native-token-transfer\",\n PermissionType.NATIVE_TOKEN_TRANSFER,\n Type.Object({\n allowance: TypeHex(),\n }),\n \"allows transfer of native tokens from the account\",\n);\n\nconst Erc20TokenTransfer = Permission(\n \"erc20-token-transfer\",\n PermissionType.ERC20_TOKEN_TRANSFER,\n Type.Object({\n allowance: TypeHex(),\n address: TypeAddress,\n }),\n \"allows transfer or approval of erc20 tokens from the account\",\n);\n\nconst GasLimit = Permission(\n \"gas-limit\",\n PermissionType.GAS_LIMIT,\n Type.Object({\n limit: TypeHex(),\n }),\n \"allows the key to spend gas for UOs\",\n);\n\nconst ContractAccess = Permission(\n \"contract-access\",\n PermissionType.CONTRACT_ACCESS,\n Type.Object({\n address: TypeAddress,\n }),\n \"grants access to all functions in a contract\",\n);\n\nconst AccountFunction = Permission(\n \"account-functions\",\n PermissionType.ACCOUNT_FUNCTIONS,\n Type.Object({\n functions: Type.Array(TypeHex(), { minItems: 1 }),\n }),\n \"grants access to functions in the account\",\n);\n\nconst AllExternalFunctionAccess = Permission(\n \"functions-on-all-contracts\",\n PermissionType.FUNCTIONS_ON_ALL_CONTRACTS,\n Type.Object({\n functions: Type.Array(TypeHex(), { minItems: 1 }),\n }),\n \"access to a function selector in any address or contract\",\n);\n\nconst ContractFunctionAccess = Permission(\n \"functions-on-contract\",\n PermissionType.FUNCTIONS_ON_CONTRACT,\n Type.Object({\n address: TypeAddress,\n functions: Type.Array(TypeHex(), { minItems: 1 }),\n }),\n \"grants access to specified functions on a specific contract\",\n);\n\nconst Root = Permission(\n \"root\",\n PermissionType.ROOT,\n Type.Optional(Type.Never()),\n \"grants full access to everything\",\n);\n\nexport const TypePermission = Type.Union([\n // 7715 permissions\n NativeTokenTransfer,\n Erc20TokenTransfer,\n GasLimit,\n // additional permissions\n ContractAccess,\n AccountFunction,\n AllExternalFunctionAccess,\n ContractFunctionAccess,\n Root,\n]);\n\nexport const PermissionsArray = Type.Array(TypePermission, { minItems: 1 });\n\nexport const PermissionsContext = Type.Object({\n context: TypeHex(),\n});\n\nexport const PermissionsData = Type.Object({\n chainId: TypeHex(),\n expiry: Type.Optional(Type.Number()),\n key: KeySigner,\n permissions: PermissionsArray,\n});\n\nexport const PermissionsCapability = Type.Union([\n PermissionsContext,\n // TODO: support permissions object here instead of only context-encoded permissions\n // PermissionsData,\n]);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACL,IAAI,GAKL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEnE,MAAM,UAAU,GAAG,CAKjB,UAAuB,EAAE,eAAe;AACxC,QAAqB,EAAE,4BAA4B;AACnD,IAAW,EACX,WAAmB,EACoB,EAAE;IACzC,OAAO,IAAI,CAAC,SAAS,CACnB,IAAI,CAAC,MAAM,CACT;QACE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC5B,IAAI;KACL,EACD,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,UAAU,EAAE,EAAE,CACxC,CACF;SACE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClB,GAAG,KAAK;QACR,IAAI,EAAE,UAAU,EAAE,gBAAgB;KACnC,CAAC,CAAC;SACF,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClB,GAAG,KAAK;QACR,IAAI,EAAE,QAAQ,EAAE,gBAAgB;KACjC,CAAC,CAAU,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,UAAU,CACpC,uBAAuB,EACvB,cAAc,CAAC,qBAAqB,EACp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B;IAClB,gBAAgB;IAChB,oFAAoF;IACpF,mBAAmB;CACpB,CAAC,CAAC","sourcesContent":["import { PermissionType } from \"@account-kit/smart-contracts/experimental\";\nimport {\n Type,\n type TLiteral,\n type TLiteralValue,\n type TObject,\n type TSchema,\n} from \"@sinclair/typebox\";\nimport { KeySigner, TypeAddress, TypeHex } from \"../../schemas.js\";\n\nconst Permission = <\n TData extends TSchema,\n TLiteralVal extends TLiteralValue,\n TType extends TLiteral<TLiteralVal>,\n>(\n typeString: TLiteralVal, // e.g., \"root\"\n typeEnum: TLiteralVal, // e.g., PermissionType.ROOT\n data: TData,\n description: string,\n): TObject<{ type: TType; data: TData }> => {\n return Type.Transform(\n Type.Object(\n {\n type: Type.Literal(typeEnum),\n data,\n },\n { description, title: `${typeString}` },\n ),\n )\n .Decode((value) => ({\n ...value,\n type: typeString, // enum → string\n }))\n .Encode((value) => ({\n ...value,\n type: typeEnum, // string → enum\n })) as never;\n};\n\nconst NativeTokenTransfer = Permission(\n \"native-token-transfer\",\n PermissionType.NATIVE_TOKEN_TRANSFER,\n Type.Object({\n allowance: TypeHex(),\n }),\n \"allows transfer of native tokens from the account\",\n);\n\nconst Erc20TokenTransfer = Permission(\n \"erc20-token-transfer\",\n PermissionType.ERC20_TOKEN_TRANSFER,\n Type.Object({\n allowance: TypeHex(),\n address: TypeAddress,\n }),\n \"allows transfer or approval of erc20 tokens from the account\",\n);\n\nconst GasLimit = Permission(\n \"gas-limit\",\n PermissionType.GAS_LIMIT,\n Type.Object({\n limit: TypeHex(),\n }),\n \"allows the key to spend gas for UOs\",\n);\n\nconst ContractAccess = Permission(\n \"contract-access\",\n PermissionType.CONTRACT_ACCESS,\n Type.Object({\n address: TypeAddress,\n }),\n \"grants access to all functions in a contract\",\n);\n\nconst AccountFunction = Permission(\n \"account-functions\",\n PermissionType.ACCOUNT_FUNCTIONS,\n Type.Object({\n functions: Type.Array(TypeHex(), { minItems: 1 }),\n }),\n \"grants access to functions in the account\",\n);\n\nconst AllExternalFunctionAccess = Permission(\n \"functions-on-all-contracts\",\n PermissionType.FUNCTIONS_ON_ALL_CONTRACTS,\n Type.Object({\n functions: Type.Array(TypeHex(), { minItems: 1 }),\n }),\n \"access to a function selector in any address or contract\",\n);\n\nconst ContractFunctionAccess = Permission(\n \"functions-on-contract\",\n PermissionType.FUNCTIONS_ON_CONTRACT,\n Type.Object({\n address: TypeAddress,\n functions: Type.Array(TypeHex(), { minItems: 1 }),\n }),\n \"grants access to specified functions on a specific contract\",\n);\n\nconst Root = Permission(\n \"root\",\n PermissionType.ROOT,\n Type.Optional(Type.Never()),\n \"grants full access to everything\",\n);\n\nexport const TypePermission = Type.Union([\n // 7715 permissions\n NativeTokenTransfer,\n Erc20TokenTransfer,\n GasLimit,\n // additional permissions\n ContractAccess,\n AccountFunction,\n AllExternalFunctionAccess,\n ContractFunctionAccess,\n Root,\n]);\n\nexport const PermissionsArray = Type.Array(TypePermission, { minItems: 1 });\n\nexport const PermissionsContext = Type.Object(\n {\n context: TypeHex(),\n },\n {\n title: \"Permissions context\",\n },\n);\n\nexport const RemotePermission = Type.Object(\n {\n sessionId: TypeHex(),\n signature: TypeHex(),\n },\n {\n title: \"Remote permission\",\n },\n);\n\nexport const PermissionsData = Type.Object({\n chainId: TypeHex(),\n expiry: Type.Optional(Type.Integer()),\n key: KeySigner,\n permissions: PermissionsArray,\n});\n\nexport const PermissionsCapability = Type.Union([\n PermissionsContext,\n RemotePermission,\n // TODO: support permissions object here instead of only context-encoded permissions\n // PermissionsData,\n]);\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { Static } from "@sinclair/typebox";
2
2
  import { type Hex } from "viem";
3
- import type { PermissionsData } from ".";
4
- import type { KeySigner } from "../../schemas";
3
+ import type { KeySigner } from "../../schemas.ts";
4
+ import type { PermissionsCapability, PermissionsData } from "./index.ts";
5
5
  export declare const SESSION_ID_LENGTH_BYTES = 16;
6
6
  export declare const ENTITY_ID_LENGTH_BYTES = 4;
7
7
  export declare const PermissionsContextVersion: {
@@ -30,7 +30,7 @@ type DecodedPermissionsContext = {
30
30
  isGlobalValidation: boolean;
31
31
  });
32
32
  export declare const encodePermissionsContext: (context: DecodedPermissionsContext) => Hex;
33
- export declare const decodePermissionsContext: (input: Hex) => DecodedPermissionsContext;
33
+ export declare const decodePermissionsContext: (capability: Static<typeof PermissionsCapability>) => DecodedPermissionsContext;
34
34
  export declare const prefixSignatureKeyType: (sig: Hex, type: KeySigner["type"]) => Hex;
35
35
  export declare const isGlobalValidation: (data: Pick<Static<typeof PermissionsData>, "permissions">) => boolean;
36
36
  export {};
@@ -31,7 +31,15 @@ export const encodePermissionsContext = (context) => {
31
31
  return assertNever(context, "Unexpected context version");
32
32
  }
33
33
  };
34
- export const decodePermissionsContext = (input) => {
34
+ export const decodePermissionsContext = (capability) => {
35
+ if (!("context" in capability)) {
36
+ return {
37
+ contextVersion: "REMOTE_MODE_DEFERRED_ACTION",
38
+ sessionId: capability.sessionId,
39
+ signature: capability.signature,
40
+ };
41
+ }
42
+ const input = capability.context;
35
43
  const contextVersion = sliceHex(input, 0, 1);
36
44
  switch (contextVersion) {
37
45
  case "0x00": {
@@ -1 +1 @@
1
- {"version":3,"file":"mav2.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/mav2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAY,MAAM,MAAM,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,2BAA2B,EAAE,MAAM;IACnC,0BAA0B,EAAE,MAAM;IAClC,mBAAmB,EAAE,MAAM;CACnB,CAAC;AA8BX,MAAM,CAAC,MAAM,wBAAwB,GA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4B;gBAC5C,cAAc;aACf,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,kBAAkB,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC;YAC5D,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,sBAAsB,GAAG,CAAC,CAAC,CAAC;YAChE,OAAO;gBACL,cAAc,EAAE,qBAAqB;gBACrC,kBAAkB;gBAClB,QAAQ;aACT,CAAC;QACJ,CAAC;QACD;YACE,OAAO,WAAW,CAChB,cAAc,EACd,+BAA+B,cAAc,EAAE,CAChD,CAAC;IACN,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,GAAQ,EACR,IAAuB,EAClB,EAAE;IACP,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,WAAW;YACd,OAAO,SAAS,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAClC,KAAK,UAAU;YACb,OAAO,SAAS,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAClC;YACE,OAAO,WAAW,CAAC,IAAI,EAAE,6BAA6B,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,IAAyD,EAChD,EAAE;IACX,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;AACtE,CAAC,CAAC","sourcesContent":["import { PermissionType } from \"@account-kit/smart-contracts/experimental\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { concatHex, sliceHex, type Hex } from \"viem\";\nimport type { PermissionsData } from \".\";\nimport type { KeySigner } from \"../../schemas\";\nimport { assertNever } from \"../../utils.js\";\n\nexport const SESSION_ID_LENGTH_BYTES = 16;\nexport const ENTITY_ID_LENGTH_BYTES = 4;\n\nexport const PermissionsContextVersion = {\n REMOTE_MODE_DEFERRED_ACTION: \"0x00\",\n LOCAL_MODE_DEFERRED_ACTION: \"0x01\",\n NON_DEFERRED_ACTION: \"0x02\",\n} as const;\n\ntype ContextVersionHex =\n (typeof PermissionsContextVersion)[keyof typeof PermissionsContextVersion];\n\ntype DecodedPermissionsContext = {\n contextVersion: keyof typeof PermissionsContextVersion;\n} & (\n | {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\";\n sessionId: Hex;\n signature: Hex;\n deferredAction?: never;\n }\n | {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\";\n deferredAction: Hex;\n sessionId?: never;\n signature?: never;\n }\n | {\n contextVersion: \"NON_DEFERRED_ACTION\";\n deferredAction?: never;\n sessionId?: never;\n signature?: never;\n entityId: Hex;\n isGlobalValidation: boolean;\n }\n);\n\nexport const encodePermissionsContext = (\n context: DecodedPermissionsContext,\n): Hex => {\n switch (context.contextVersion) {\n case \"REMOTE_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.REMOTE_MODE_DEFERRED_ACTION,\n context.sessionId,\n context.signature,\n ]);\n case \"LOCAL_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.LOCAL_MODE_DEFERRED_ACTION,\n context.deferredAction,\n ]);\n case \"NON_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.NON_DEFERRED_ACTION,\n context.isGlobalValidation ? \"0x01\" : \"0x00\",\n context.entityId,\n ]);\n default:\n return assertNever(context, \"Unexpected context version\");\n }\n};\n\nexport const decodePermissionsContext = (\n input: Hex,\n): DecodedPermissionsContext => {\n const contextVersion = sliceHex(input, 0, 1) as ContextVersionHex;\n switch (contextVersion) {\n case \"0x00\": {\n const sessionId = sliceHex(input, 1, SESSION_ID_LENGTH_BYTES + 1);\n const signature = sliceHex(input, SESSION_ID_LENGTH_BYTES + 1);\n return {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId,\n signature,\n };\n }\n case \"0x01\": {\n const deferredAction = sliceHex(input, 1);\n return {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\",\n deferredAction,\n };\n }\n case \"0x02\": {\n const isGlobalValidation = sliceHex(input, 1, 2) === \"0x01\";\n const entityId = sliceHex(input, 2, ENTITY_ID_LENGTH_BYTES + 2);\n return {\n contextVersion: \"NON_DEFERRED_ACTION\",\n isGlobalValidation,\n entityId,\n };\n }\n default:\n return assertNever(\n contextVersion,\n `Unexpected context version: ${contextVersion}`,\n );\n }\n};\n\nexport const prefixSignatureKeyType = (\n sig: Hex,\n type: KeySigner[\"type\"],\n): Hex => {\n switch (type) {\n case \"secp256k1\":\n return concatHex([\"0x00\", sig]);\n case \"contract\":\n return concatHex([\"0x01\", sig]);\n default:\n return assertNever(type, \"Unexpected session key type\");\n }\n};\n\nexport const isGlobalValidation = (\n data: Pick<Static<typeof PermissionsData>, \"permissions\">,\n): boolean => {\n return data.permissions.some((p) => p.type === PermissionType.ROOT);\n};\n"]}
1
+ {"version":3,"file":"mav2.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/mav2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAY,MAAM,MAAM,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,2BAA2B,EAAE,MAAM;IACnC,0BAA0B,EAAE,MAAM;IAClC,mBAAmB,EAAE,MAAM;CACnB,CAAC;AA8BX,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,OAAkC,EAC7B,EAAE;IACP,QA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C,CAAC","sourcesContent":["import { PermissionType } from \"@account-kit/smart-contracts/experimental\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { concatHex, sliceHex, type Hex } from \"viem\";\nimport type { KeySigner } from \"../../schemas.ts\";\nimport { assertNever } from \"../../utils.js\";\nimport type { PermissionsCapability, PermissionsData } from \"./index.ts\";\n\nexport const SESSION_ID_LENGTH_BYTES = 16;\nexport const ENTITY_ID_LENGTH_BYTES = 4;\n\nexport const PermissionsContextVersion = {\n REMOTE_MODE_DEFERRED_ACTION: \"0x00\",\n LOCAL_MODE_DEFERRED_ACTION: \"0x01\",\n NON_DEFERRED_ACTION: \"0x02\",\n} as const;\n\ntype ContextVersionHex =\n (typeof PermissionsContextVersion)[keyof typeof PermissionsContextVersion];\n\ntype DecodedPermissionsContext = {\n contextVersion: keyof typeof PermissionsContextVersion;\n} & (\n | {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\";\n sessionId: Hex;\n signature: Hex;\n deferredAction?: never;\n }\n | {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\";\n deferredAction: Hex;\n sessionId?: never;\n signature?: never;\n }\n | {\n contextVersion: \"NON_DEFERRED_ACTION\";\n deferredAction?: never;\n sessionId?: never;\n signature?: never;\n entityId: Hex;\n isGlobalValidation: boolean;\n }\n);\n\nexport const encodePermissionsContext = (\n context: DecodedPermissionsContext,\n): Hex => {\n switch (context.contextVersion) {\n case \"REMOTE_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.REMOTE_MODE_DEFERRED_ACTION,\n context.sessionId,\n context.signature,\n ]);\n case \"LOCAL_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.LOCAL_MODE_DEFERRED_ACTION,\n context.deferredAction,\n ]);\n case \"NON_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.NON_DEFERRED_ACTION,\n context.isGlobalValidation ? \"0x01\" : \"0x00\",\n context.entityId,\n ]);\n default:\n return assertNever(context, \"Unexpected context version\");\n }\n};\n\nexport const decodePermissionsContext = (\n capability: Static<typeof PermissionsCapability>,\n): DecodedPermissionsContext => {\n if (!(\"context\" in capability)) {\n return {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId: capability.sessionId,\n signature: capability.signature,\n };\n }\n\n const input = capability.context;\n\n const contextVersion = sliceHex(input, 0, 1) as ContextVersionHex;\n switch (contextVersion) {\n case \"0x00\": {\n const sessionId = sliceHex(input, 1, SESSION_ID_LENGTH_BYTES + 1);\n const signature = sliceHex(input, SESSION_ID_LENGTH_BYTES + 1);\n return {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId,\n signature,\n };\n }\n case \"0x01\": {\n const deferredAction = sliceHex(input, 1);\n return {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\",\n deferredAction,\n };\n }\n case \"0x02\": {\n const isGlobalValidation = sliceHex(input, 1, 2) === \"0x01\";\n const entityId = sliceHex(input, 2, ENTITY_ID_LENGTH_BYTES + 2);\n return {\n contextVersion: \"NON_DEFERRED_ACTION\",\n isGlobalValidation,\n entityId,\n };\n }\n default:\n return assertNever(\n contextVersion,\n `Unexpected context version: ${contextVersion}`,\n );\n }\n};\n\nexport const prefixSignatureKeyType = (\n sig: Hex,\n type: KeySigner[\"type\"],\n): Hex => {\n switch (type) {\n case \"secp256k1\":\n return concatHex([\"0x00\", sig]);\n case \"contract\":\n return concatHex([\"0x01\", sig]);\n default:\n return assertNever(type, \"Unexpected session key type\");\n }\n};\n\nexport const isGlobalValidation = (\n data: Pick<Static<typeof PermissionsData>, \"permissions\">,\n): boolean => {\n return data.permissions.some((p) => p.type === PermissionType.ROOT);\n};\n"]}
@@ -1,10 +1,35 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import type { Static } from "@sinclair/typebox";
3
3
  import type { Address } from "abitype";
4
- import type { wallet_createAccount } from "../../rpc/request";
5
- import type { InnerWalletApiClient } from "../../types";
4
+ import type { wallet_createAccount } from "../../rpc/request.ts";
5
+ import type { InnerWalletApiClient } from "../../types.ts";
6
6
  export type CreateAccountParams = Omit<Extract<Static<typeof wallet_createAccount>["Request"]["params"][0], {
7
7
  signerAddress: Address;
8
8
  }>, "signerAddress">;
9
9
  export type CreateAccountResult = Static<typeof wallet_createAccount>["ReturnType"];
10
+ /**
11
+ * Creates a new account for the provided signer using the wallet API client.
12
+ * This method is primarily used to import existing accounts.
13
+ * For most cases, you should use requestAccount instead.
14
+ * If the account already exists, an error will be thrown.
15
+ *
16
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
17
+ * @param {SmartAccountSigner} signer - The signer that will be associated with the account
18
+ * @param {CreateAccountParams} params - Parameters for creating the account
19
+ * @param {string} [params.id] - Optional UUID v4 identifier for the account
20
+ * @param {object} params.creationOptions - Options for account creation
21
+ * @param {string} [params.creationOptions.accountType] - Currently only "sma-b" (Modular Account v2) is supported
22
+ * @param {string} [params.creationOptions.salt] - Optional hex string to use as salt for account creation
23
+ * @returns {Promise<CreateAccountResult>} A Promise that resolves to the created account information
24
+ *
25
+ * @example
26
+ * // Create a new account with a custom salt
27
+ * const account = await client.createAccount({
28
+ * creationOptions: {
29
+ * accountType: "sma-b",
30
+ * salt: "0x04"
31
+ * }
32
+ * });
33
+ * console.log(`Created account at address: ${account.accountAddress}`);
34
+ */
10
35
  export declare function createAccount(client: InnerWalletApiClient, signer: SmartAccountSigner, params: CreateAccountParams): Promise<CreateAccountResult>;
@@ -1,3 +1,28 @@
1
+ /**
2
+ * Creates a new account for the provided signer using the wallet API client.
3
+ * This method is primarily used to import existing accounts.
4
+ * For most cases, you should use requestAccount instead.
5
+ * If the account already exists, an error will be thrown.
6
+ *
7
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
8
+ * @param {SmartAccountSigner} signer - The signer that will be associated with the account
9
+ * @param {CreateAccountParams} params - Parameters for creating the account
10
+ * @param {string} [params.id] - Optional UUID v4 identifier for the account
11
+ * @param {object} params.creationOptions - Options for account creation
12
+ * @param {string} [params.creationOptions.accountType] - Currently only "sma-b" (Modular Account v2) is supported
13
+ * @param {string} [params.creationOptions.salt] - Optional hex string to use as salt for account creation
14
+ * @returns {Promise<CreateAccountResult>} A Promise that resolves to the created account information
15
+ *
16
+ * @example
17
+ * // Create a new account with a custom salt
18
+ * const account = await client.createAccount({
19
+ * creationOptions: {
20
+ * accountType: "sma-b",
21
+ * salt: "0x04"
22
+ * }
23
+ * });
24
+ * console.log(`Created account at address: ${account.accountAddress}`);
25
+ */
1
26
  export async function createAccount(client, signer, params) {
2
27
  return client.request({
3
28
  method: "wallet_createAccount",
@@ -1 +1 @@
1
- {"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/createAccount.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA0B,EAC1B,MAA2B;IAE3B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,sBAAsB;QAC9B,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC;KAClE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport type { Address } from \"abitype\";\nimport type { wallet_createAccount } from \"../../rpc/request\";\nimport type { InnerWalletApiClient } from \"../../types\";\n\nexport type CreateAccountParams = Omit<\n Extract<\n Static<typeof wallet_createAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\"\n>;\n\nexport type CreateAccountResult = Static<\n typeof wallet_createAccount\n>[\"ReturnType\"];\n\nexport async function createAccount(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: CreateAccountParams,\n): Promise<CreateAccountResult> {\n return client.request({\n method: \"wallet_createAccount\",\n params: [{ signerAddress: await signer.getAddress(), ...params }],\n });\n}\n"]}
1
+ {"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/createAccount.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA0B,EAC1B,MAA2B;IAE3B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,sBAAsB;QAC9B,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC;KAClE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport type { Address } from \"abitype\";\nimport type { wallet_createAccount } from \"../../rpc/request.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type CreateAccountParams = Omit<\n Extract<\n Static<typeof wallet_createAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\"\n>;\n\nexport type CreateAccountResult = Static<\n typeof wallet_createAccount\n>[\"ReturnType\"];\n\n/**\n * Creates a new account for the provided signer using the wallet API client.\n * This method is primarily used to import existing accounts.\n * For most cases, you should use requestAccount instead.\n * If the account already exists, an error will be thrown.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer that will be associated with the account\n * @param {CreateAccountParams} params - Parameters for creating the account\n * @param {string} [params.id] - Optional UUID v4 identifier for the account\n * @param {object} params.creationOptions - Options for account creation\n * @param {string} [params.creationOptions.accountType] - Currently only \"sma-b\" (Modular Account v2) is supported\n * @param {string} [params.creationOptions.salt] - Optional hex string to use as salt for account creation\n * @returns {Promise<CreateAccountResult>} A Promise that resolves to the created account information\n *\n * @example\n * // Create a new account with a custom salt\n * const account = await client.createAccount({\n * creationOptions: {\n * accountType: \"sma-b\",\n * salt: \"0x04\"\n * }\n * });\n * console.log(`Created account at address: ${account.accountAddress}`);\n */\nexport async function createAccount(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: CreateAccountParams,\n): Promise<CreateAccountResult> {\n return client.request({\n method: \"wallet_createAccount\",\n params: [{ signerAddress: await signer.getAddress(), ...params }],\n });\n}\n"]}
@@ -1,6 +1,25 @@
1
1
  import type { Address, JsonRpcAccount } from "viem";
2
- import type { GetCallsStatusParams as IsomorphicGetCallsStatusParams, GetCallsStatusResponse as IsomorphicGetCallsStatusResult } from "../../isomorphic/actions/getCallsStatus";
3
- import type { InnerWalletApiClient } from "../../types";
2
+ import type { GetCallsStatusParams as IsomorphicGetCallsStatusParams, GetCallsStatusResponse as IsomorphicGetCallsStatusResult } from "../../isomorphic/actions/getCallsStatus.ts";
3
+ import type { InnerWalletApiClient } from "../../types.ts";
4
4
  export type GetCallsStatusParams = IsomorphicGetCallsStatusParams;
5
5
  export type GetCallsStatusResult = IsomorphicGetCallsStatusResult;
6
+ /**
7
+ * Gets the status of a prepared call by its ID.
8
+ * This method is used to check the execution status of calls sent via sendPreparedCalls.
9
+ *
10
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
11
+ * @param {GetCallsStatusParams} params - The ID of the prepared call to check
12
+ * @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:
13
+ * - id: The hex ID of the call
14
+ * - chainId: The chain ID in hex format
15
+ * - status: The current status of the batch execution
16
+ * - receipts: Optional array of transaction receipts if the batch has been executed
17
+ *
18
+ * @example
19
+ * // After sending prepared calls
20
+ * const sendResult = await client.sendPreparedCalls({...});
21
+ *
22
+ * // Check the status of the first call ID
23
+ * const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);
24
+ */
6
25
  export declare function getCallsStatus<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, params: GetCallsStatusParams): Promise<GetCallsStatusResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,MAAM,CAAC;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Address, JsonRpcAccount } from \"viem\";\nimport type {\n GetCallsStatusParams as IsomorphicGetCallsStatusParams,\n GetCallsStatusResponse as IsomorphicGetCallsStatusResult,\n} from \"../../isomorphic/actions/getCallsStatus\";\nimport type { InnerWalletApiClient } from \"../../types\";\n\nexport type GetCallsStatusParams = IsomorphicGetCallsStatusParams;\n\nexport type GetCallsStatusResult = IsomorphicGetCallsStatusResult;\n\nexport async function getCallsStatus<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult>;\n\nexport async function getCallsStatus(\n client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\n return await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params],\n });\n}\n"]}
1
+ {"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"AAuCA,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,MAAM,CAAC;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Address, JsonRpcAccount } from \"viem\";\nimport type {\n GetCallsStatusParams as IsomorphicGetCallsStatusParams,\n GetCallsStatusResponse as IsomorphicGetCallsStatusResult,\n} from \"../../isomorphic/actions/getCallsStatus.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GetCallsStatusParams = IsomorphicGetCallsStatusParams;\n\nexport type GetCallsStatusResult = IsomorphicGetCallsStatusResult;\n\n/**\n * Gets the status of a prepared call by its ID.\n * This method is used to check the execution status of calls sent via sendPreparedCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {GetCallsStatusParams} params - The ID of the prepared call to check\n * @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:\n * - id: The hex ID of the call\n * - chainId: The chain ID in hex format\n * - status: The current status of the batch execution\n * - receipts: Optional array of transaction receipts if the batch has been executed\n *\n * @example\n * // After sending prepared calls\n * const sendResult = await client.sendPreparedCalls({...});\n *\n * // Check the status of the first call ID\n * const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);\n */\nexport async function getCallsStatus<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult>;\n\nexport async function getCallsStatus(\n client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\n return await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params],\n });\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import { type Address, type Hex, type IsUndefined, type JsonRpcAccount } from "viem";
2
- import type { InnerWalletApiClient } from "../../types";
2
+ import type { InnerWalletApiClient } from "../../types.ts";
3
3
  import type { SmartAccountSigner } from "@aa-sdk/core";
4
- import type { CreateSessionParams } from "../../isomorphic/actions/createSession";
4
+ import type { CreateSessionParams } from "../../isomorphic/actions/createSession.ts";
5
+ import { TypeEip7702AuthExtendedFields } from "../../schemas.js";
6
+ import type { Static } from "@sinclair/typebox";
5
7
  export type GrantPermissionsParams<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined> = Omit<CreateSessionParams, "account" | "chainId"> & (IsUndefined<TAccount> extends true ? {
6
8
  account: Address;
7
9
  } : {
@@ -9,5 +11,115 @@ export type GrantPermissionsParams<TAccount extends JsonRpcAccount<Address> | un
9
11
  });
10
12
  export type GrantPermissionsResult = {
11
13
  context: Hex;
14
+ signedAuthorization?: Static<typeof TypeEip7702AuthExtendedFields>;
12
15
  };
16
+ /**
17
+ * Grants permissions to a smart account by creating a session.
18
+ * This allows another key to perform operations on behalf of the account.
19
+ *
20
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
21
+ * @param {SmartAccountSigner} signer - The signer of the smart account
22
+ * @param {GrantPermissionsParams} params - The parameters for granting permissions
23
+ * @param {Address} [params.account] - The account address (required if client was not initialized with an account)
24
+ * @param {number} params.expiry - Unix timestamp when the permissions expire
25
+ * @param {object} params.key - The session key information
26
+ * @param {string} params.key.publicKey - The public key of the session key
27
+ * @param {string} params.key.type - The type of the key (e.g., "secp256k1")
28
+ * @param {Array} params.permissions - Array of permission objects defining what the session key can do
29
+ * @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier
30
+ * @returns {Hex} result.context - A hex identifier for the granted permissions context
31
+ * @returns {Static<typeof TypeEip7702AuthExtendedFields>} result.signedAuthorization - The EIP-7702 authorization fields, if applicable
32
+ *
33
+ * @example
34
+ * // Create a session key and grant root permissions
35
+ * const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
36
+ * const account = await client.requestAccount();
37
+ *
38
+ * const permissions = await client.grantPermissions({
39
+ * account: account.address,
40
+ * expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
41
+ * key: {
42
+ * publicKey: await sessionKey.getAddress(),
43
+ * type: "secp256k1",
44
+ * },
45
+ * permissions: [{ type: "root" }],
46
+ * });
47
+ *
48
+ * // Use the permissions to prepare a call
49
+ * const preparedCall = await client.prepareCalls({
50
+ * calls: [{ to: zeroAddress, value: "0x0" }],
51
+ * from: account.address,
52
+ * capabilities: {
53
+ * paymasterService: {
54
+ * policyId: "your-paymaster-policy-id",
55
+ * },
56
+ * permissions,
57
+ * },
58
+ * });
59
+ *
60
+ * // Sign with the session key
61
+ * const signature = await signSignatureRequest(
62
+ * sessionKey,
63
+ * preparedCall.signatureRequest,
64
+ * );
65
+ *
66
+ * // Send the prepared call using the session key
67
+ * const result = await client.sendPreparedCalls({
68
+ * ...preparedCall,
69
+ * signature,
70
+ * capabilities: {
71
+ * permissions,
72
+ * },
73
+ * });
74
+ *
75
+ * @example
76
+ * // Create a session key and grant root permissions using a 7702 account
77
+ * const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
78
+ * const account = await client.requestAccount({
79
+ * creationHint: {
80
+ * accountType: "7702",
81
+ * }
82
+ * });
83
+ *
84
+ * const permissions = await client.grantPermissions({
85
+ * account: account.address,
86
+ * expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
87
+ * key: {
88
+ * publicKey: await sessionKey.getAddress(),
89
+ * type: "secp256k1",
90
+ * },
91
+ * permissions: [{ type: "root" }],
92
+ * });
93
+ *
94
+ * // Use the permissions to prepare a call
95
+ * const preparedCall = await client.prepareCalls({
96
+ * calls: [{ to: zeroAddress, value: "0x0" }],
97
+ * from: account.address,
98
+ * capabilities: {
99
+ * paymasterService: {
100
+ * policyId: "your-paymaster-policy-id",
101
+ * },
102
+ * permissions,
103
+ * },
104
+ * });
105
+ *
106
+ * // Sign with the session key
107
+ * // If the 7702 account delegation is not yet installed, the result
108
+ * // here will include a `signedAuthorization` field that that
109
+ * // must be included when sending the account's first call.
110
+ * const { signedAuthorization, ...signature} = await signSignatureRequest(
111
+ * sessionKey,
112
+ * preparedCall.signatureRequest,
113
+ * );
114
+ *
115
+ * // Send the prepared call using the session key
116
+ * const result = await client.sendPreparedCalls({
117
+ * ...preparedCall,
118
+ * signature,
119
+ * signedAuthorization,
120
+ * capabilities: {
121
+ * permissions,
122
+ * },
123
+ * });
124
+ */
13
125
  export declare function grantPermissions<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, signer: SmartAccountSigner, params: GrantPermissionsParams<TAccount>): Promise<GrantPermissionsResult>;
@@ -1,4 +1,5 @@
1
1
  import { toHex, } from "viem";
2
+ import { TypeEip7702AuthExtendedFields } from "../../schemas.js";
2
3
  export async function grantPermissions(client, signer, params) {
3
4
  if (client.account && !params.account) {
4
5
  params.account = client.account.address;
@@ -1 +1 @@
1
- {"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,GACN,MAAM,MAAM,CAAC;AA4Bd,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA4B,EAC5B,MAA0B,EAC1B,MAA8B;IAE9B,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE;QACrC,GAAG,MAAM;QACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;KAChC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type Address,\n type Hex,\n type IsUndefined,\n type JsonRpcAccount,\n toHex,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types\";\nimport type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { CreateSessionParams } from \"../../isomorphic/actions/createSession\";\n\nexport type GrantPermissionsParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = Omit<CreateSessionParams, \"account\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never });\n\nexport type GrantPermissionsResult = {\n context: Hex;\n};\n\nexport async function grantPermissions<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params: GrantPermissionsParams<TAccount>,\n): Promise<GrantPermissionsResult>;\n\nexport async function grantPermissions(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: GrantPermissionsParams,\n): Promise<GrantPermissionsResult> {\n if (client.account && !params.account) {\n params.account = client.account.address;\n }\n\n return client.grantPermissions(signer, {\n ...params,\n chainId: toHex(client.chain.id),\n });\n}\n"]}
1
+ {"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,GACN,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAwIjE,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA4B,EAC5B,MAA0B,EAC1B,MAA8B;IAE9B,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE;QACrC,GAAG,MAAM;QACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;KAChC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type Address,\n type Hex,\n type IsUndefined,\n type JsonRpcAccount,\n toHex,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { CreateSessionParams } from \"../../isomorphic/actions/createSession.ts\";\nimport { TypeEip7702AuthExtendedFields } from \"../../schemas.js\";\nimport type { Static } from \"@sinclair/typebox\";\n\nexport type GrantPermissionsParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = Omit<CreateSessionParams, \"account\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never });\n\nexport type GrantPermissionsResult = {\n context: Hex;\n signedAuthorization?: Static<typeof TypeEip7702AuthExtendedFields>;\n};\n\n/**\n * Grants permissions to a smart account by creating a session.\n * This allows another key to perform operations on behalf of the account.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {GrantPermissionsParams} params - The parameters for granting permissions\n * @param {Address} [params.account] - The account address (required if client was not initialized with an account)\n * @param {number} params.expiry - Unix timestamp when the permissions expire\n * @param {object} params.key - The session key information\n * @param {string} params.key.publicKey - The public key of the session key\n * @param {string} params.key.type - The type of the key (e.g., \"secp256k1\")\n * @param {Array} params.permissions - Array of permission objects defining what the session key can do\n * @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier\n * @returns {Hex} result.context - A hex identifier for the granted permissions context\n * @returns {Static<typeof TypeEip7702AuthExtendedFields>} result.signedAuthorization - The EIP-7702 authorization fields, if applicable\n *\n * @example\n * // Create a session key and grant root permissions\n * const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n * const account = await client.requestAccount();\n *\n * const permissions = await client.grantPermissions({\n * account: account.address,\n * expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now\n * key: {\n * publicKey: await sessionKey.getAddress(),\n * type: \"secp256k1\",\n * },\n * permissions: [{ type: \"root\" }],\n * });\n *\n * // Use the permissions to prepare a call\n * const preparedCall = await client.prepareCalls({\n * calls: [{ to: zeroAddress, value: \"0x0\" }],\n * from: account.address,\n * capabilities: {\n * paymasterService: {\n * policyId: \"your-paymaster-policy-id\",\n * },\n * permissions,\n * },\n * });\n *\n * // Sign with the session key\n * const signature = await signSignatureRequest(\n * sessionKey,\n * preparedCall.signatureRequest,\n * );\n *\n * // Send the prepared call using the session key\n * const result = await client.sendPreparedCalls({\n * ...preparedCall,\n * signature,\n * capabilities: {\n * permissions,\n * },\n * });\n *\n * @example\n * // Create a session key and grant root permissions using a 7702 account\n * const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n * const account = await client.requestAccount({\n * creationHint: {\n * accountType: \"7702\",\n * }\n * });\n *\n * const permissions = await client.grantPermissions({\n * account: account.address,\n * expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now\n * key: {\n * publicKey: await sessionKey.getAddress(),\n * type: \"secp256k1\",\n * },\n * permissions: [{ type: \"root\" }],\n * });\n *\n * // Use the permissions to prepare a call\n * const preparedCall = await client.prepareCalls({\n * calls: [{ to: zeroAddress, value: \"0x0\" }],\n * from: account.address,\n * capabilities: {\n * paymasterService: {\n * policyId: \"your-paymaster-policy-id\",\n * },\n * permissions,\n * },\n * });\n *\n * // Sign with the session key\n * // If the 7702 account delegation is not yet installed, the result\n * // here will include a `signedAuthorization` field that that\n * // must be included when sending the account's first call.\n * const { signedAuthorization, ...signature} = await signSignatureRequest(\n * sessionKey,\n * preparedCall.signatureRequest,\n * );\n *\n * // Send the prepared call using the session key\n * const result = await client.sendPreparedCalls({\n * ...preparedCall,\n * signature,\n * signedAuthorization,\n * capabilities: {\n * permissions,\n * },\n * });\n */\nexport async function grantPermissions<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params: GrantPermissionsParams<TAccount>,\n): Promise<GrantPermissionsResult>;\n\nexport async function grantPermissions(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: GrantPermissionsParams,\n): Promise<GrantPermissionsResult> {\n if (client.account && !params.account) {\n params.account = client.account.address;\n }\n\n return client.grantPermissions(signer, {\n ...params,\n chainId: toHex(client.chain.id),\n });\n}\n"]}
@@ -1,6 +1,30 @@
1
1
  import type { Static } from "@sinclair/typebox";
2
- import type { wallet_listAccounts } from "../../rpc/request";
3
- import type { InnerWalletApiClient } from "../../types";
2
+ import type { wallet_listAccounts } from "../../rpc/request.ts";
3
+ import type { InnerWalletApiClient } from "../../types.ts";
4
4
  export type ListAccountsParams = Static<typeof wallet_listAccounts>["Request"]["params"][0];
5
5
  export type ListAccountsResult = Static<typeof wallet_listAccounts>["ReturnType"];
6
+ /**
7
+ * Lists all smart accounts for a given signer using the wallet API client.
8
+ *
9
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
10
+ * @param {ListAccountsParams} params - Parameters for listing accounts
11
+ * @param {string} params.signerAddress - The address of the signer to list accounts for
12
+ * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
13
+ * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
14
+ * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
15
+ *
16
+ * @example
17
+ * // Fetch the first page of accounts
18
+ * const firstPage = await client.listAccounts({
19
+ * signerAddress: "0x123...",
20
+ * limit: 10
21
+ * });
22
+ *
23
+ * // If an 'after' cursor exists, use it to fetch the next page
24
+ * const nextPage = await client.listAccounts({
25
+ * signerAddress: "0x123...",
26
+ * limit: 10,
27
+ * after: firstPage.meta.after
28
+ * });
29
+ */
6
30
  export declare function listAccounts(client: InnerWalletApiClient, params: ListAccountsParams): Promise<ListAccountsResult>;
@@ -1,3 +1,27 @@
1
+ /**
2
+ * Lists all smart accounts for a given signer using the wallet API client.
3
+ *
4
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
5
+ * @param {ListAccountsParams} params - Parameters for listing accounts
6
+ * @param {string} params.signerAddress - The address of the signer to list accounts for
7
+ * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
8
+ * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
9
+ * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
10
+ *
11
+ * @example
12
+ * // Fetch the first page of accounts
13
+ * const firstPage = await client.listAccounts({
14
+ * signerAddress: "0x123...",
15
+ * limit: 10
16
+ * });
17
+ *
18
+ * // If an 'after' cursor exists, use it to fetch the next page
19
+ * const nextPage = await client.listAccounts({
20
+ * signerAddress: "0x123...",
21
+ * limit: 10,
22
+ * after: firstPage.meta.after
23
+ * });
24
+ */
1
25
  export async function listAccounts(client, params) {
2
26
  return client.request({ method: "wallet_listAccounts", params: [params] });
3
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type { wallet_listAccounts } from \"../../rpc/request\";\nimport type { InnerWalletApiClient } from \"../../types\";\n\nexport type ListAccountsParams = Static<\n typeof wallet_listAccounts\n>[\"Request\"][\"params\"][0];\n\nexport type ListAccountsResult = Static<\n typeof wallet_listAccounts\n>[\"ReturnType\"];\n\nexport async function listAccounts(\n client: InnerWalletApiClient,\n params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n return client.request({ method: \"wallet_listAccounts\", params: [params] });\n}\n"]}
1
+ {"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type { wallet_listAccounts } from \"../../rpc/request.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type ListAccountsParams = Static<\n typeof wallet_listAccounts\n>[\"Request\"][\"params\"][0];\n\nexport type ListAccountsResult = Static<\n typeof wallet_listAccounts\n>[\"ReturnType\"];\n\n/**\n * Lists all smart accounts for a given signer using the wallet API client.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {ListAccountsParams} params - Parameters for listing accounts\n * @param {string} params.signerAddress - The address of the signer to list accounts for\n * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)\n * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages\n * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata\n *\n * @example\n * // Fetch the first page of accounts\n * const firstPage = await client.listAccounts({\n * signerAddress: \"0x123...\",\n * limit: 10\n * });\n *\n * // If an 'after' cursor exists, use it to fetch the next page\n * const nextPage = await client.listAccounts({\n * signerAddress: \"0x123...\",\n * limit: 10,\n * after: firstPage.meta.after\n * });\n */\nexport async function listAccounts(\n client: InnerWalletApiClient,\n params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n return client.request({ method: \"wallet_listAccounts\", params: [params] });\n}\n"]}