@account-kit/infra 4.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/actions/simulateUserOperationChanges.d.ts +5 -0
  3. package/dist/cjs/actions/simulateUserOperationChanges.js +24 -0
  4. package/dist/cjs/actions/simulateUserOperationChanges.js.map +1 -0
  5. package/dist/cjs/actions/types.d.ts +39 -0
  6. package/dist/cjs/actions/types.js +17 -0
  7. package/dist/cjs/actions/types.js.map +1 -0
  8. package/dist/cjs/chains.d.ts +5 -0
  9. package/dist/cjs/chains.js +16 -0
  10. package/dist/cjs/chains.js.map +1 -0
  11. package/dist/cjs/client/decorators/alchemyEnhancedApis.d.ts +14 -0
  12. package/dist/cjs/client/decorators/alchemyEnhancedApis.js +26 -0
  13. package/dist/cjs/client/decorators/alchemyEnhancedApis.js.map +1 -0
  14. package/dist/cjs/client/decorators/smartAccount.d.ts +7 -0
  15. package/dist/cjs/client/decorators/smartAccount.js +9 -0
  16. package/dist/cjs/client/decorators/smartAccount.js.map +1 -0
  17. package/dist/cjs/client/internal/smartAccountClientFromRpc.d.ts +11 -0
  18. package/dist/cjs/client/internal/smartAccountClientFromRpc.js +55 -0
  19. package/dist/cjs/client/internal/smartAccountClientFromRpc.js.map +1 -0
  20. package/dist/cjs/client/isAlchemySmartAccountClient.d.ts +5539 -0
  21. package/dist/cjs/client/isAlchemySmartAccountClient.js +9 -0
  22. package/dist/cjs/client/isAlchemySmartAccountClient.js.map +1 -0
  23. package/dist/cjs/client/rpcClient.d.ts +8 -0
  24. package/dist/cjs/client/rpcClient.js +36 -0
  25. package/dist/cjs/client/rpcClient.js.map +1 -0
  26. package/dist/cjs/client/smartAccountClient.d.ts +18 -0
  27. package/dist/cjs/client/smartAccountClient.js +32 -0
  28. package/dist/cjs/client/smartAccountClient.js.map +1 -0
  29. package/dist/cjs/client/types.d.ts +76 -0
  30. package/dist/cjs/client/types.js +3 -0
  31. package/dist/cjs/client/types.js.map +1 -0
  32. package/dist/cjs/defaults.d.ts +3 -0
  33. package/dist/cjs/defaults.js +23 -0
  34. package/dist/cjs/defaults.js.map +1 -0
  35. package/dist/cjs/errors/base.d.ts +4 -0
  36. package/dist/cjs/errors/base.js +18 -0
  37. package/dist/cjs/errors/base.js.map +1 -0
  38. package/dist/cjs/errors/rpcUrl.d.ts +10 -0
  39. package/dist/cjs/errors/rpcUrl.js +26 -0
  40. package/dist/cjs/errors/rpcUrl.js.map +1 -0
  41. package/dist/cjs/gas-manager.d.ts +6 -0
  42. package/dist/cjs/gas-manager.js +35 -0
  43. package/dist/cjs/gas-manager.js.map +1 -0
  44. package/dist/cjs/index.d.ts +24 -0
  45. package/dist/cjs/index.js +32 -0
  46. package/dist/cjs/index.js.map +1 -0
  47. package/dist/cjs/middleware/feeEstimator.d.ts +3 -0
  48. package/dist/cjs/middleware/feeEstimator.js +26 -0
  49. package/dist/cjs/middleware/feeEstimator.js.map +1 -0
  50. package/dist/cjs/middleware/gasManager.d.ts +29 -0
  51. package/dist/cjs/middleware/gasManager.js +148 -0
  52. package/dist/cjs/middleware/gasManager.js.map +1 -0
  53. package/dist/cjs/middleware/userOperationSimulator.d.ts +3 -0
  54. package/dist/cjs/middleware/userOperationSimulator.js +21 -0
  55. package/dist/cjs/middleware/userOperationSimulator.js.map +1 -0
  56. package/dist/cjs/package.json +1 -0
  57. package/dist/cjs/schema.d.ts +396 -0
  58. package/dist/cjs/schema.js +26 -0
  59. package/dist/cjs/schema.js.map +1 -0
  60. package/dist/cjs/type.d.ts +3 -0
  61. package/dist/cjs/type.js +3 -0
  62. package/dist/cjs/type.js.map +1 -0
  63. package/dist/cjs/version.d.ts +1 -0
  64. package/dist/cjs/version.js +5 -0
  65. package/dist/cjs/version.js.map +1 -0
  66. package/dist/esm/actions/simulateUserOperationChanges.d.ts +5 -0
  67. package/dist/esm/actions/simulateUserOperationChanges.js +20 -0
  68. package/dist/esm/actions/simulateUserOperationChanges.js.map +1 -0
  69. package/dist/esm/actions/types.d.ts +39 -0
  70. package/dist/esm/actions/types.js +14 -0
  71. package/dist/esm/actions/types.js.map +1 -0
  72. package/dist/esm/chains.d.ts +5 -0
  73. package/dist/esm/chains.js +12 -0
  74. package/dist/esm/chains.js.map +1 -0
  75. package/dist/esm/client/decorators/alchemyEnhancedApis.d.ts +14 -0
  76. package/dist/esm/client/decorators/alchemyEnhancedApis.js +22 -0
  77. package/dist/esm/client/decorators/alchemyEnhancedApis.js.map +1 -0
  78. package/dist/esm/client/decorators/smartAccount.d.ts +7 -0
  79. package/dist/esm/client/decorators/smartAccount.js +5 -0
  80. package/dist/esm/client/decorators/smartAccount.js.map +1 -0
  81. package/dist/esm/client/internal/smartAccountClientFromRpc.d.ts +11 -0
  82. package/dist/esm/client/internal/smartAccountClientFromRpc.js +50 -0
  83. package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +1 -0
  84. package/dist/esm/client/isAlchemySmartAccountClient.d.ts +5539 -0
  85. package/dist/esm/client/isAlchemySmartAccountClient.js +5 -0
  86. package/dist/esm/client/isAlchemySmartAccountClient.js.map +1 -0
  87. package/dist/esm/client/rpcClient.d.ts +8 -0
  88. package/dist/esm/client/rpcClient.js +32 -0
  89. package/dist/esm/client/rpcClient.js.map +1 -0
  90. package/dist/esm/client/smartAccountClient.d.ts +18 -0
  91. package/dist/esm/client/smartAccountClient.js +31 -0
  92. package/dist/esm/client/smartAccountClient.js.map +1 -0
  93. package/dist/esm/client/types.d.ts +76 -0
  94. package/dist/esm/client/types.js +2 -0
  95. package/dist/esm/client/types.js.map +1 -0
  96. package/dist/esm/defaults.d.ts +3 -0
  97. package/dist/esm/defaults.js +19 -0
  98. package/dist/esm/defaults.js.map +1 -0
  99. package/dist/esm/errors/base.d.ts +4 -0
  100. package/dist/esm/errors/base.js +14 -0
  101. package/dist/esm/errors/base.js.map +1 -0
  102. package/dist/esm/errors/rpcUrl.d.ts +10 -0
  103. package/dist/esm/errors/rpcUrl.js +24 -0
  104. package/dist/esm/errors/rpcUrl.js.map +1 -0
  105. package/dist/esm/gas-manager.d.ts +6 -0
  106. package/dist/esm/gas-manager.js +31 -0
  107. package/dist/esm/gas-manager.js.map +1 -0
  108. package/dist/esm/index.d.ts +24 -0
  109. package/dist/esm/index.js +15 -0
  110. package/dist/esm/index.js.map +1 -0
  111. package/dist/esm/middleware/feeEstimator.d.ts +3 -0
  112. package/dist/esm/middleware/feeEstimator.js +22 -0
  113. package/dist/esm/middleware/feeEstimator.js.map +1 -0
  114. package/dist/esm/middleware/gasManager.d.ts +29 -0
  115. package/dist/esm/middleware/gasManager.js +144 -0
  116. package/dist/esm/middleware/gasManager.js.map +1 -0
  117. package/dist/esm/middleware/userOperationSimulator.d.ts +3 -0
  118. package/dist/esm/middleware/userOperationSimulator.js +17 -0
  119. package/dist/esm/middleware/userOperationSimulator.js.map +1 -0
  120. package/dist/esm/package.json +1 -0
  121. package/dist/esm/schema.d.ts +396 -0
  122. package/dist/esm/schema.js +20 -0
  123. package/dist/esm/schema.js.map +1 -0
  124. package/dist/esm/type.d.ts +3 -0
  125. package/dist/esm/type.js +2 -0
  126. package/dist/esm/type.js.map +1 -0
  127. package/dist/esm/version.d.ts +1 -0
  128. package/dist/esm/version.js +2 -0
  129. package/dist/esm/version.js.map +1 -0
  130. package/dist/types/actions/simulateUserOperationChanges.d.ts +6 -0
  131. package/dist/types/actions/simulateUserOperationChanges.d.ts.map +1 -0
  132. package/dist/types/actions/types.d.ts +44 -0
  133. package/dist/types/actions/types.d.ts.map +1 -0
  134. package/dist/types/chains.d.ts +6 -0
  135. package/dist/types/chains.d.ts.map +1 -0
  136. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +15 -0
  137. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -0
  138. package/dist/types/client/decorators/smartAccount.d.ts +8 -0
  139. package/dist/types/client/decorators/smartAccount.d.ts.map +1 -0
  140. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +19 -0
  141. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts.map +1 -0
  142. package/dist/types/client/isAlchemySmartAccountClient.d.ts +5540 -0
  143. package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -0
  144. package/dist/types/client/rpcClient.d.ts +9 -0
  145. package/dist/types/client/rpcClient.d.ts.map +1 -0
  146. package/dist/types/client/smartAccountClient.d.ts +19 -0
  147. package/dist/types/client/smartAccountClient.d.ts.map +1 -0
  148. package/dist/types/client/types.d.ts +77 -0
  149. package/dist/types/client/types.d.ts.map +1 -0
  150. package/dist/types/defaults.d.ts +4 -0
  151. package/dist/types/defaults.d.ts.map +1 -0
  152. package/dist/types/errors/base.d.ts +5 -0
  153. package/dist/types/errors/base.d.ts.map +1 -0
  154. package/dist/types/errors/rpcUrl.d.ts +11 -0
  155. package/dist/types/errors/rpcUrl.d.ts.map +1 -0
  156. package/dist/types/gas-manager.d.ts +7 -0
  157. package/dist/types/gas-manager.d.ts.map +1 -0
  158. package/dist/types/index.d.ts +25 -0
  159. package/dist/types/index.d.ts.map +1 -0
  160. package/dist/types/middleware/feeEstimator.d.ts +4 -0
  161. package/dist/types/middleware/feeEstimator.d.ts.map +1 -0
  162. package/dist/types/middleware/gasManager.d.ts +94 -0
  163. package/dist/types/middleware/gasManager.d.ts.map +1 -0
  164. package/dist/types/middleware/userOperationSimulator.d.ts +4 -0
  165. package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -0
  166. package/dist/types/schema.d.ts +397 -0
  167. package/dist/types/schema.d.ts.map +1 -0
  168. package/dist/types/type.d.ts +4 -0
  169. package/dist/types/type.d.ts.map +1 -0
  170. package/dist/types/version.d.ts +2 -0
  171. package/dist/types/version.d.ts.map +1 -0
  172. package/package.json +75 -0
  173. package/src/actions/simulateUserOperationChanges.ts +49 -0
  174. package/src/actions/types.ts +49 -0
  175. package/src/chains.ts +19 -0
  176. package/src/client/decorators/alchemyEnhancedApis.ts +54 -0
  177. package/src/client/decorators/smartAccount.ts +37 -0
  178. package/src/client/internal/smartAccountClientFromRpc.ts +121 -0
  179. package/src/client/isAlchemySmartAccountClient.ts +19 -0
  180. package/src/client/rpcClient.ts +50 -0
  181. package/src/client/smartAccountClient.ts +153 -0
  182. package/src/client/types.ts +89 -0
  183. package/src/defaults.ts +34 -0
  184. package/src/errors/base.ts +7 -0
  185. package/src/errors/rpcUrl.ts +20 -0
  186. package/src/gas-manager.ts +53 -0
  187. package/src/index.ts +24 -0
  188. package/src/middleware/feeEstimator.ts +40 -0
  189. package/src/middleware/gasManager.ts +432 -0
  190. package/src/middleware/userOperationSimulator.ts +26 -0
  191. package/src/schema.ts +33 -0
  192. package/src/type.ts +4 -0
  193. package/src/version.ts +3 -0
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ import type { AlchemyProviderConfigSchema } from "./schema.js";
3
+ export type AlchemyProviderConfig = z.input<typeof AlchemyProviderConfigSchema>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"","sourcesContent":["import { z } from \"zod\";\nimport type { AlchemyProviderConfigSchema } from \"./schema.js\";\n\nexport type AlchemyProviderConfig = z.input<typeof AlchemyProviderConfigSchema>;\n"]}
@@ -0,0 +1 @@
1
+ export declare const VERSION = "4.0.0-alpha.0";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = void 0;
4
+ exports.VERSION = "4.0.0-alpha.0";
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.0.0-alpha.0\";\n"]}
@@ -0,0 +1,5 @@
1
+ import { type SendUserOperationParameters, type SmartContractAccount } from "@aa-sdk/core";
2
+ import type { Chain, Client, Transport } from "viem";
3
+ import type { AlchemyRpcSchema } from "../client/types.js";
4
+ import type { SimulateUserOperationAssetChangesResponse } from "./types.js";
5
+ export declare const simulateUserOperationChanges: <TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined>(client: Client<Transport, TChain, TAccount, AlchemyRpcSchema>, args: SendUserOperationParameters<TAccount>) => Promise<SimulateUserOperationAssetChangesResponse>;
@@ -0,0 +1,20 @@
1
+ import { AccountNotFoundError, IncompatibleClientError, deepHexlify, } from "@aa-sdk/core";
2
+ import { isAlchemySmartAccountClient } from "../client/isAlchemySmartAccountClient.js";
3
+ export const simulateUserOperationChanges = async (client, { account = client.account, overrides, ...params }) => {
4
+ if (!account) {
5
+ throw new AccountNotFoundError();
6
+ }
7
+ if (!isAlchemySmartAccountClient(client)) {
8
+ throw new IncompatibleClientError("AlchemySmartAccountClient", "SimulateUserOperationAssetChanges", client);
9
+ }
10
+ const uoStruct = deepHexlify(await client.buildUserOperation({
11
+ ...params,
12
+ account,
13
+ overrides,
14
+ }));
15
+ return client.request({
16
+ method: "alchemy_simulateUserOperationAssetChanges",
17
+ params: [uoStruct, account.getEntryPoint().address],
18
+ });
19
+ };
20
+ //# sourceMappingURL=simulateUserOperationChanges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulateUserOperationChanges.js","sourceRoot":"","sources":["../../../src/actions/simulateUserOperationChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,WAAW,GAGZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAIvF,MAAM,CAAC,MAAM,4BAA4B,GAQiB,KAAK,EAC7D,MAAM,EACN,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAClD,EAAE;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,uBAAuB,CAC/B,2BAA2B,EAC3B,mCAAmC,EACnC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAC1B,MAAM,MAAM,CAAC,kBAAkB,CAAC;QAC9B,GAAG,MAAM;QACT,OAAO;QACP,SAAS;KACV,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,2CAA2C;QACnD,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC;KACpD,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n IncompatibleClientError,\n deepHexlify,\n type SendUserOperationParameters,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport { isAlchemySmartAccountClient } from \"../client/isAlchemySmartAccountClient.js\";\nimport type { AlchemyRpcSchema } from \"../client/types.js\";\nimport type { SimulateUserOperationAssetChangesResponse } from \"./types.js\";\n\nexport const simulateUserOperationChanges: <\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<Transport, TChain, TAccount, AlchemyRpcSchema>,\n args: SendUserOperationParameters<TAccount>\n) => Promise<SimulateUserOperationAssetChangesResponse> = async (\n client,\n { account = client.account, overrides, ...params }\n) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isAlchemySmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"AlchemySmartAccountClient\",\n \"SimulateUserOperationAssetChanges\",\n client\n );\n }\n\n const uoStruct = deepHexlify(\n await client.buildUserOperation({\n ...params,\n account,\n overrides,\n })\n );\n\n return client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [uoStruct, account.getEntryPoint().address],\n });\n};\n"]}
@@ -0,0 +1,39 @@
1
+ import type { UserOperationStruct } from "@aa-sdk/core";
2
+ import type { Address, Hash } from "viem";
3
+ export declare enum SimulateAssetType {
4
+ NATIVE = "NATIVE",
5
+ ERC20 = "ERC20",
6
+ ERC721 = "ERC721",
7
+ ERC1155 = "ERC1155",
8
+ SPECIAL_NFT = "SPECIAL_NFT"
9
+ }
10
+ export declare enum SimulateChangeType {
11
+ APPROVE = "APPROVE",
12
+ TRANSFER = "TRANSFER"
13
+ }
14
+ export type SimulateUserOperationAssetChangesRequest = [
15
+ UserOperationStruct,
16
+ entryPoint: Address,
17
+ blockNumber?: Hash
18
+ ];
19
+ export type SimulateUserOperationAssetChangesResponse = {
20
+ changes: SimulateAssetChange[];
21
+ error?: SimulateAssetChangesError;
22
+ };
23
+ export interface SimulateAssetChangesError extends Record<string, any> {
24
+ message: string;
25
+ }
26
+ export interface SimulateAssetChange {
27
+ assetType: SimulateAssetType;
28
+ changeType: SimulateChangeType;
29
+ from: Address;
30
+ to: Address;
31
+ rawAmount?: string;
32
+ amount?: string;
33
+ contactAddress: Address;
34
+ tokenId?: string;
35
+ decimals: number;
36
+ symbol: string;
37
+ name?: string;
38
+ logo?: string;
39
+ }
@@ -0,0 +1,14 @@
1
+ export var SimulateAssetType;
2
+ (function (SimulateAssetType) {
3
+ SimulateAssetType["NATIVE"] = "NATIVE";
4
+ SimulateAssetType["ERC20"] = "ERC20";
5
+ SimulateAssetType["ERC721"] = "ERC721";
6
+ SimulateAssetType["ERC1155"] = "ERC1155";
7
+ SimulateAssetType["SPECIAL_NFT"] = "SPECIAL_NFT";
8
+ })(SimulateAssetType || (SimulateAssetType = {}));
9
+ export var SimulateChangeType;
10
+ (function (SimulateChangeType) {
11
+ SimulateChangeType["APPROVE"] = "APPROVE";
12
+ SimulateChangeType["TRANSFER"] = "TRANSFER";
13
+ })(SimulateChangeType || (SimulateChangeType = {}));
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,iBAUX;AAVD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,oCAAe,CAAA;IACf,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IAKnB,gDAA2B,CAAA;AAC7B,CAAC,EAVW,iBAAiB,KAAjB,iBAAiB,QAU5B;AAED,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B","sourcesContent":["import type { UserOperationStruct } from \"@aa-sdk/core\";\nimport type { Address, Hash } from \"viem\";\n\nexport enum SimulateAssetType {\n NATIVE = \"NATIVE\",\n ERC20 = \"ERC20\",\n ERC721 = \"ERC721\",\n ERC1155 = \"ERC1155\",\n /**\n * Special contracts that don't follow ERC 721/1155. Currently limited to\n * CryptoKitties and CryptoPunks.\n */\n SPECIAL_NFT = \"SPECIAL_NFT\",\n}\n\nexport enum SimulateChangeType {\n APPROVE = \"APPROVE\",\n TRANSFER = \"TRANSFER\",\n}\n\nexport type SimulateUserOperationAssetChangesRequest = [\n UserOperationStruct,\n entryPoint: Address,\n blockNumber?: Hash\n];\n\nexport type SimulateUserOperationAssetChangesResponse = {\n changes: SimulateAssetChange[];\n error?: SimulateAssetChangesError;\n};\n\nexport interface SimulateAssetChangesError extends Record<string, any> {\n message: string;\n}\n\nexport interface SimulateAssetChange {\n assetType: SimulateAssetType;\n changeType: SimulateChangeType;\n from: Address;\n to: Address;\n rawAmount?: string;\n amount?: string;\n contactAddress: Address;\n tokenId?: string;\n decimals: number;\n symbol: string;\n name?: string;\n logo?: string;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { Chain } from "viem";
2
+ export declare const defineAlchemyChain: ({ chain, rpcBaseUrl, }: {
3
+ chain: Chain;
4
+ rpcBaseUrl: string;
5
+ }) => Chain;
@@ -0,0 +1,12 @@
1
+ export const defineAlchemyChain = ({ chain, rpcBaseUrl, }) => {
2
+ return {
3
+ ...chain,
4
+ rpcUrls: {
5
+ ...chain.rpcUrls,
6
+ alchemy: {
7
+ http: [rpcBaseUrl],
8
+ },
9
+ },
10
+ };
11
+ };
12
+ //# sourceMappingURL=chains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,EACL,UAAU,GAIX,EAAS,EAAE;IACV,OAAO;QACL,GAAG,KAAK;QACR,OAAO,EAAE;YACP,GAAG,KAAK,CAAC,OAAO;YAChB,OAAO,EAAE;gBACP,IAAI,EAAE,CAAC,UAAU,CAAC;aACnB;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Chain } from \"viem\";\n\nexport const defineAlchemyChain = ({\n chain,\n rpcBaseUrl,\n}: {\n chain: Chain;\n rpcBaseUrl: string;\n}): Chain => {\n return {\n ...chain,\n rpcUrls: {\n ...chain.rpcUrls,\n alchemy: {\n http: [rpcBaseUrl],\n },\n },\n };\n};\n"]}
@@ -0,0 +1,14 @@
1
+ import type { SmartContractAccount } from "@aa-sdk/core";
2
+ import type { Alchemy } from "alchemy-sdk";
3
+ import type { Chain, Transport } from "viem";
4
+ import type { AlchemySmartAccountClient } from "../smartAccountClient.js";
5
+ export type AlchemyEnhancedApis = {
6
+ core: Alchemy["core"];
7
+ nft: Alchemy["nft"];
8
+ transact: Alchemy["transact"];
9
+ debug: Alchemy["debug"];
10
+ ws: Alchemy["ws"];
11
+ notify: Alchemy["notify"];
12
+ config: Alchemy["config"];
13
+ };
14
+ export declare const alchemyEnhancedApiActions: (alchemy: Alchemy) => <TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined>(client: AlchemySmartAccountClient<TTransport, TChain, TAccount>) => AlchemyEnhancedApis;
@@ -0,0 +1,22 @@
1
+ import { AlchemySdkClientSchema } from "../../schema.js";
2
+ export const alchemyEnhancedApiActions = (alchemy) => (client) => {
3
+ const alchemySdk = AlchemySdkClientSchema.parse(alchemy);
4
+ if (client.transport.type === "http") {
5
+ const { url } = client.transport;
6
+ if (client.transport.type === "http" &&
7
+ alchemy.config.url &&
8
+ alchemy.config.url !== url) {
9
+ throw new Error("Alchemy SDK client JSON-RPC URL must match AlchemyProvider JSON-RPC URL");
10
+ }
11
+ }
12
+ return {
13
+ core: alchemySdk.core,
14
+ nft: alchemySdk.nft,
15
+ transact: alchemySdk.transact,
16
+ debug: alchemySdk.debug,
17
+ ws: alchemySdk.ws,
18
+ notify: alchemySdk.notify,
19
+ config: alchemySdk.config,
20
+ };
21
+ };
22
+ //# sourceMappingURL=alchemyEnhancedApis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alchemyEnhancedApis.js","sourceRoot":"","sources":["../../../../src/client/decorators/alchemyEnhancedApis.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAazD,MAAM,CAAC,MAAM,yBAAyB,GAUX,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;IACjD,MAAM,UAAU,GAAG,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEzD,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACrC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,SACa,CAAC;QAErC,IACE,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM;YAChC,OAAO,CAAC,MAAM,CAAC,GAAG;YAClB,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,GAAG,EAC1B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Alchemy } from \"alchemy-sdk\";\nimport type { Chain, HttpTransport, Transport } from \"viem\";\nimport { AlchemySdkClientSchema } from \"../../schema.js\";\nimport type { AlchemySmartAccountClient } from \"../smartAccountClient.js\";\n\nexport type AlchemyEnhancedApis = {\n core: Alchemy[\"core\"];\n nft: Alchemy[\"nft\"];\n transact: Alchemy[\"transact\"];\n debug: Alchemy[\"debug\"];\n ws: Alchemy[\"ws\"];\n notify: Alchemy[\"notify\"];\n config: Alchemy[\"config\"];\n};\n\nexport const alchemyEnhancedApiActions: (\n alchemy: Alchemy\n) => <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: AlchemySmartAccountClient<TTransport, TChain, TAccount>\n) => AlchemyEnhancedApis = (alchemy) => (client) => {\n const alchemySdk = AlchemySdkClientSchema.parse(alchemy);\n\n if (client.transport.type === \"http\") {\n const { url } = client.transport as ReturnType<HttpTransport>[\"config\"] &\n ReturnType<HttpTransport>[\"value\"];\n\n if (\n client.transport.type === \"http\" &&\n alchemy.config.url &&\n alchemy.config.url !== url\n ) {\n throw new Error(\n \"Alchemy SDK client JSON-RPC URL must match AlchemyProvider JSON-RPC URL\"\n );\n }\n }\n\n return {\n core: alchemySdk.core,\n nft: alchemySdk.nft,\n transact: alchemySdk.transact,\n debug: alchemySdk.debug,\n ws: alchemySdk.ws,\n notify: alchemySdk.notify,\n config: alchemySdk.config,\n };\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import type { SendUserOperationParameters, SmartContractAccount, UserOperationContext } from "@aa-sdk/core";
2
+ import type { Chain, Client, Transport } from "viem";
3
+ import type { SimulateUserOperationAssetChangesResponse } from "../../actions/types.js";
4
+ export type AlchemySmartAccountClientActions<TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined> = {
5
+ simulateUserOperation: (args: SendUserOperationParameters<TAccount, TContext>) => Promise<SimulateUserOperationAssetChangesResponse>;
6
+ };
7
+ export declare const alchemyActions: <TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: Client<TTransport, TChain, TAccount>) => AlchemySmartAccountClientActions<TAccount, TContext>;
@@ -0,0 +1,5 @@
1
+ import { simulateUserOperationChanges } from "../../actions/simulateUserOperationChanges.js";
2
+ export const alchemyActions = (client) => ({
3
+ simulateUserOperation: async (args) => simulateUserOperationChanges(client, args),
4
+ });
5
+ //# sourceMappingURL=smartAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartAccount.js","sourceRoot":"","sources":["../../../../src/client/decorators/smartAccount.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAgB7F,MAAM,CAAC,MAAM,cAAc,GAWiC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvE,qBAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACpC,4BAA4B,CAAC,MAAM,EAAE,IAAI,CAAC;CAC7C,CAAC,CAAC","sourcesContent":["import type {\n SendUserOperationParameters,\n SmartContractAccount,\n UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport { simulateUserOperationChanges } from \"../../actions/simulateUserOperationChanges.js\";\nimport type { SimulateUserOperationAssetChangesResponse } from \"../../actions/types.js\";\n\nexport type AlchemySmartAccountClientActions<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n simulateUserOperation: (\n args: SendUserOperationParameters<TAccount, TContext>\n ) => Promise<SimulateUserOperationAssetChangesResponse>;\n};\n\nexport const alchemyActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n) => AlchemySmartAccountClientActions<TAccount, TContext> = (client) => ({\n simulateUserOperation: async (args) =>\n simulateUserOperationChanges(client, args),\n});\n"]}
@@ -0,0 +1,11 @@
1
+ import { type SmartContractAccount, type SmartContractAccountWithSigner, type UserOperationContext } from "@aa-sdk/core";
2
+ import type { Chain, CustomTransport, Transport } from "viem";
3
+ import type { AlchemySmartAccountClient, AlchemySmartAccountClientConfig } from "../smartAccountClient.js";
4
+ import type { ClientWithAlchemyMethods } from "../types.js";
5
+ export type CreateAlchemySmartAccountClientFromRpcClient<TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined> = Omit<AlchemySmartAccountClientConfig<Transport, Chain, TAccount, TContext>, "rpcUrl" | "chain" | "apiKey" | "jwt"> & {
6
+ client: ClientWithAlchemyMethods;
7
+ };
8
+ export declare function getSignerTypeHeader<TAccount extends SmartContractAccountWithSigner>(account: TAccount): {
9
+ "Alchemy-Aa-Sdk-Signer": string;
10
+ };
11
+ export declare function createAlchemySmartAccountClientFromRpcClient<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(args: CreateAlchemySmartAccountClientFromRpcClient<TAccount, TContext>): AlchemySmartAccountClient<CustomTransport, TChain, TAccount, Record<string, never>, TContext>;
@@ -0,0 +1,50 @@
1
+ import { createSmartAccountClientFromExisting, getDefaultUserOperationFeeOptions, isSmartAccountWithSigner, } from "@aa-sdk/core";
2
+ import { alchemyFeeEstimator } from "../../middleware/feeEstimator.js";
3
+ import { alchemyGasManagerMiddleware } from "../../middleware/gasManager.js";
4
+ import { alchemyUserOperationSimulator } from "../../middleware/userOperationSimulator.js";
5
+ import { alchemyActions } from "../decorators/smartAccount.js";
6
+ export function getSignerTypeHeader(account) {
7
+ return { "Alchemy-Aa-Sdk-Signer": account.getSigner().signerType };
8
+ }
9
+ export function createAlchemySmartAccountClientFromRpcClient({ opts, account, useSimulation, gasManagerConfig, feeEstimator, gasEstimator, customMiddleware, signUserOperation, client, }) {
10
+ const feeOptions = opts?.feeOptions ?? getDefaultUserOperationFeeOptions(client.chain);
11
+ const scaClient = createSmartAccountClientFromExisting({
12
+ account,
13
+ client,
14
+ type: "AlchemySmartAccountClient",
15
+ opts: {
16
+ ...opts,
17
+ feeOptions,
18
+ },
19
+ customMiddleware: async (struct, args) => {
20
+ if (isSmartAccountWithSigner(args.account)) {
21
+ client.updateHeaders(getSignerTypeHeader(args.account));
22
+ }
23
+ return customMiddleware ? customMiddleware(struct, args) : struct;
24
+ },
25
+ feeEstimator: feeEstimator ?? alchemyFeeEstimator(client),
26
+ userOperationSimulator: useSimulation
27
+ ? alchemyUserOperationSimulator(client)
28
+ : undefined,
29
+ gasEstimator,
30
+ ...(gasManagerConfig &&
31
+ alchemyGasManagerMiddleware(client, {
32
+ ...gasManagerConfig,
33
+ gasEstimationOptions: {
34
+ ...gasManagerConfig.gasEstimationOptions,
35
+ disableGasEstimation: gasManagerConfig.gasEstimationOptions?.disableGasEstimation ??
36
+ false,
37
+ fallbackFeeDataGetter: gasManagerConfig.gasEstimationOptions?.fallbackFeeDataGetter ??
38
+ feeEstimator,
39
+ fallbackGasEstimator: gasManagerConfig.gasEstimationOptions?.fallbackGasEstimator ??
40
+ gasEstimator,
41
+ },
42
+ })),
43
+ signUserOperation,
44
+ }).extend(alchemyActions);
45
+ if (account && isSmartAccountWithSigner(account)) {
46
+ client.updateHeaders(getSignerTypeHeader(account));
47
+ }
48
+ return scaClient;
49
+ }
50
+ //# sourceMappingURL=smartAccountClientFromRpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartAccountClientFromRpc.js","sourceRoot":"","sources":["../../../../src/client/internal/smartAccountClientFromRpc.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,iCAAiC,EACjC,wBAAwB,GAIzB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAmB/D,MAAM,UAAU,mBAAmB,CAEjC,OAAiB;IACjB,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;AACrE,CAAC;AA2BD,MAAM,UAAU,4CAA4C,CAAC,EAC3D,IAAI,EACJ,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,GACuC;IAC7C,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,iCAAiC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEtE,MAAM,SAAS,GAAG,oCAAoC,CAAC;QACrD,OAAO;QACP,MAAM;QACN,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,UAAU;SACX;QACD,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YACvC,IAAI,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3C,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1D,CAAC;YAED,OAAO,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACpE,CAAC;QACD,YAAY,EAAE,YAAY,IAAI,mBAAmB,CAAC,MAAM,CAAC;QACzD,sBAAsB,EAAE,aAAa;YACnC,CAAC,CAAC,6BAA6B,CAAC,MAAM,CAAC;YACvC,CAAC,CAAC,SAAS;QACb,YAAY;QACZ,GAAG,CAAC,gBAAgB;YAClB,2BAA2B,CAAC,MAAM,EAAE;gBAClC,GAAG,gBAAgB;gBACnB,oBAAoB,EAAE;oBACpB,GAAG,gBAAgB,CAAC,oBAAoB;oBACxC,oBAAoB,EAClB,gBAAgB,CAAC,oBAAoB,EAAE,oBAAoB;wBAC3D,KAAK;oBACP,qBAAqB,EACnB,gBAAgB,CAAC,oBAAoB,EAAE,qBAAqB;wBAC5D,YAAY;oBACd,oBAAoB,EAClB,gBAAgB,CAAC,oBAAoB,EAAE,oBAAoB;wBAC3D,YAAY;iBACf;aACF,CAAC,CAAC;QACL,iBAAiB;KAClB,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAE1B,IAAI,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n createSmartAccountClientFromExisting,\n getDefaultUserOperationFeeOptions,\n isSmartAccountWithSigner,\n type SmartContractAccount,\n type SmartContractAccountWithSigner,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { Chain, CustomTransport, Transport } from \"viem\";\nimport { alchemyFeeEstimator } from \"../../middleware/feeEstimator.js\";\nimport { alchemyGasManagerMiddleware } from \"../../middleware/gasManager.js\";\nimport { alchemyUserOperationSimulator } from \"../../middleware/userOperationSimulator.js\";\nimport { alchemyActions } from \"../decorators/smartAccount.js\";\nimport type {\n AlchemySmartAccountClient,\n AlchemySmartAccountClientConfig,\n} from \"../smartAccountClient.js\";\nimport type { ClientWithAlchemyMethods } from \"../types.js\";\n\nexport type CreateAlchemySmartAccountClientFromRpcClient<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Omit<\n AlchemySmartAccountClientConfig<Transport, Chain, TAccount, TContext>,\n \"rpcUrl\" | \"chain\" | \"apiKey\" | \"jwt\"\n> & { client: ClientWithAlchemyMethods };\n\nexport function getSignerTypeHeader<\n TAccount extends SmartContractAccountWithSigner\n>(account: TAccount) {\n return { \"Alchemy-Aa-Sdk-Signer\": account.getSigner().signerType };\n}\n\n/**\n * Helper method meant to be used internally to create an alchemy smart account client\n * from an existing Alchemy Rpc Client\n *\n * @param args configuration for the client\n * @returns a smart account client configured to use Alchemy's RPC\n */\nexport function createAlchemySmartAccountClientFromRpcClient<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n args: CreateAlchemySmartAccountClientFromRpcClient<TAccount, TContext>\n): AlchemySmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\nexport function createAlchemySmartAccountClientFromRpcClient({\n opts,\n account,\n useSimulation,\n gasManagerConfig,\n feeEstimator,\n gasEstimator,\n customMiddleware,\n signUserOperation,\n client,\n}: CreateAlchemySmartAccountClientFromRpcClient): AlchemySmartAccountClient {\n const feeOptions =\n opts?.feeOptions ?? getDefaultUserOperationFeeOptions(client.chain);\n\n const scaClient = createSmartAccountClientFromExisting({\n account,\n client,\n type: \"AlchemySmartAccountClient\",\n opts: {\n ...opts,\n feeOptions,\n },\n customMiddleware: async (struct, args) => {\n if (isSmartAccountWithSigner(args.account)) {\n client.updateHeaders(getSignerTypeHeader(args.account));\n }\n\n return customMiddleware ? customMiddleware(struct, args) : struct;\n },\n feeEstimator: feeEstimator ?? alchemyFeeEstimator(client),\n userOperationSimulator: useSimulation\n ? alchemyUserOperationSimulator(client)\n : undefined,\n gasEstimator,\n ...(gasManagerConfig &&\n alchemyGasManagerMiddleware(client, {\n ...gasManagerConfig,\n gasEstimationOptions: {\n ...gasManagerConfig.gasEstimationOptions,\n disableGasEstimation:\n gasManagerConfig.gasEstimationOptions?.disableGasEstimation ??\n false,\n fallbackFeeDataGetter:\n gasManagerConfig.gasEstimationOptions?.fallbackFeeDataGetter ??\n feeEstimator,\n fallbackGasEstimator:\n gasManagerConfig.gasEstimationOptions?.fallbackGasEstimator ??\n gasEstimator,\n },\n })),\n signUserOperation,\n }).extend(alchemyActions);\n\n if (account && isSmartAccountWithSigner(account)) {\n client.updateHeaders(getSignerTypeHeader(account));\n }\n\n return scaClient;\n}\n"]}