@account-kit/infra 4.0.0-alpha.5 → 4.0.0-alpha.6

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 (45) hide show
  1. package/dist/cjs/chains.d.ts +2 -0
  2. package/dist/cjs/chains.js +35 -1
  3. package/dist/cjs/chains.js.map +1 -1
  4. package/dist/cjs/client/internal/smartAccountClientFromRpc.js.map +1 -1
  5. package/dist/cjs/index.d.ts +1 -1
  6. package/dist/cjs/index.js +3 -1
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/middleware/gasManager.js +9 -4
  9. package/dist/cjs/middleware/gasManager.js.map +1 -1
  10. package/dist/cjs/middleware/userOperationSimulator.d.ts +2 -2
  11. package/dist/cjs/middleware/userOperationSimulator.js.map +1 -1
  12. package/dist/cjs/version.d.ts +1 -1
  13. package/dist/cjs/version.js +1 -1
  14. package/dist/cjs/version.js.map +1 -1
  15. package/dist/esm/chains.d.ts +2 -0
  16. package/dist/esm/chains.js +34 -0
  17. package/dist/esm/chains.js.map +1 -1
  18. package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +1 -1
  19. package/dist/esm/index.d.ts +1 -1
  20. package/dist/esm/index.js +1 -1
  21. package/dist/esm/index.js.map +1 -1
  22. package/dist/esm/middleware/gasManager.js +9 -4
  23. package/dist/esm/middleware/gasManager.js.map +1 -1
  24. package/dist/esm/middleware/userOperationSimulator.d.ts +2 -2
  25. package/dist/esm/middleware/userOperationSimulator.js.map +1 -1
  26. package/dist/esm/version.d.ts +1 -1
  27. package/dist/esm/version.js +1 -1
  28. package/dist/esm/version.js.map +1 -1
  29. package/dist/types/chains.d.ts +2 -0
  30. package/dist/types/chains.d.ts.map +1 -1
  31. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +2 -2
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/index.d.ts.map +1 -1
  34. package/dist/types/middleware/gasManager.d.ts +3 -3
  35. package/dist/types/middleware/gasManager.d.ts.map +1 -1
  36. package/dist/types/middleware/userOperationSimulator.d.ts +2 -2
  37. package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -1
  38. package/dist/types/version.d.ts +1 -1
  39. package/package.json +4 -3
  40. package/src/chains.ts +36 -0
  41. package/src/client/internal/smartAccountClientFromRpc.ts +2 -2
  42. package/src/index.ts +2 -0
  43. package/src/middleware/gasManager.ts +34 -25
  44. package/src/middleware/userOperationSimulator.ts +6 -2
  45. package/src/version.ts +1 -1
@@ -26,3 +26,5 @@ export declare const fraxtal: Chain;
26
26
  export declare const fraxtalSepolia: Chain;
27
27
  export declare const zora: Chain;
28
28
  export declare const zoraSepolia: Chain;
29
+ export declare const worldChainSepolia: Chain;
30
+ export declare const worldChain: Chain;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zoraSepolia = exports.zora = exports.fraxtalSepolia = exports.fraxtal = exports.polygon = exports.polygonAmoy = exports.polygonMumbai = exports.baseSepolia = exports.baseGoerli = exports.base = exports.sepolia = exports.optimismSepolia = exports.optimismGoerli = exports.optimism = exports.mainnet = exports.goerli = exports.arbitrumSepolia = exports.arbitrumGoerli = exports.arbitrum = exports.defineAlchemyChain = void 0;
3
+ exports.worldChain = exports.worldChainSepolia = exports.zoraSepolia = exports.zora = exports.fraxtalSepolia = exports.fraxtal = exports.polygon = exports.polygonAmoy = exports.polygonMumbai = exports.baseSepolia = exports.baseGoerli = exports.base = exports.sepolia = exports.optimismSepolia = exports.optimismGoerli = exports.optimism = exports.mainnet = exports.goerli = exports.arbitrumSepolia = exports.arbitrumGoerli = exports.arbitrum = exports.defineAlchemyChain = void 0;
4
4
  const viem_1 = require("viem");
5
5
  const chains_1 = require("viem/chains");
6
6
  const defineAlchemyChain = ({ chain, rpcBaseUrl, }) => {
@@ -178,4 +178,38 @@ exports.zoraSepolia = {
178
178
  ...chains_1.zoraSepolia.rpcUrls,
179
179
  },
180
180
  };
181
+ exports.worldChainSepolia = (0, viem_1.defineChain)({
182
+ id: 4801,
183
+ name: "World Chain Sepolia",
184
+ network: "World Chain Sepolia",
185
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
186
+ rpcUrls: {
187
+ default: {
188
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
189
+ },
190
+ public: {
191
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
192
+ },
193
+ alchemy: {
194
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
195
+ },
196
+ },
197
+ });
198
+ exports.worldChain = (0, viem_1.defineChain)({
199
+ id: 480,
200
+ name: "World Chain",
201
+ network: "World Chain",
202
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
203
+ rpcUrls: {
204
+ default: {
205
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
206
+ },
207
+ public: {
208
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
209
+ },
210
+ alchemy: {
211
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
212
+ },
213
+ },
214
+ });
181
215
  //# sourceMappingURL=chains.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":";;;AAEA,+BAAmC;AACnC,wCAmBqB;AA0Bd,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;AAhBW,QAAA,kBAAkB,sBAgB7B;AAEW,QAAA,QAAQ,GAAU;IAC7B,GAAG,iBAAG;IACN,OAAO,EAAE;QACP,GAAG,iBAAG,CAAC,OAAO;QACd,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,sCAAsC,CAAC;SAC/C;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AAA,cAAc,GAAU,IAAA,kBAAW,EAAC;IAC/C,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,iBAAiB;IACvB,cAAc,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;IACtE,OAAO,EAAE;QACP,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,sCAAsC,CAAC;SAC/C;KACF;CACF,CAAC,CAAC;AAEU,QAAA,IAAI,GAAU;IACzB,GAAG,aAAK;IACR,OAAO,EAAE;QACP,GAAG,aAAK,CAAC,OAAO;KACjB;CACF,CAAC;AAEW,QAAA,WAAW,GAAU;IAChC,GAAG,oBAAM;IACT,OAAO,EAAE;QACP,GAAG,oBAAM,CAAC,OAAO;KAClB;CACF,CAAC","sourcesContent":["import type { Chain } from \"viem\";\n\nimport { defineChain } from \"viem\";\nimport {\n arbitrum as vab,\n arbitrumGoerli as vabg,\n arbitrumSepolia as vabs,\n base as vbase,\n baseGoerli as vbaseg,\n baseSepolia as vbases,\n fraxtal as vfrax,\n goerli as vgo,\n mainnet as vmain,\n optimism as vop,\n optimismGoerli as vopg,\n optimismSepolia as vops,\n polygon as vpg,\n polygonAmoy as vpga,\n polygonMumbai as vpgm,\n sepolia as vsep,\n zora as vzora,\n zoraSepolia as vzoras,\n} from \"viem/chains\";\n\nexport type AlchemyChainConfig = {\n chain: Chain;\n rpcBaseUrl: string;\n};\n\n/**\n * Defines an Alchemy chain configuration by adding an Alchemy-specific RPC base URL to the chain's RPC URLs.\n *\n * @example\n * ```ts\n * import { defineAlchemyChain } from \"@account-kit/infra\";\n * import { sepolia } from \"viem/chains\";\n *\n * const chain = defineAlchemyChain({\n * chain: sepolia,\n * rpcBaseUrl: \"https://eth-sepolia.g.alchemy.com/v2\"\n * });\n * ```\n *\n * @param {AlchemyChainConfig} params The parameters for defining the Alchemy chain\n * @param {Chain} params.chain The original chain configuration\n * @param {string} params.rpcBaseUrl The Alchemy-specific RPC base URL\n * @returns {Chain} The updated chain configuration with the Alchemy RPC URL added\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\nexport const arbitrum: Chain = {\n ...vab,\n rpcUrls: {\n ...vab.rpcUrls,\n alchemy: {\n http: [\"https://arb-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumGoerli: Chain = {\n ...vabg,\n rpcUrls: {\n ...vabg.rpcUrls,\n alchemy: {\n http: [\"https://arb-goerli.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumSepolia: Chain = {\n ...vabs,\n rpcUrls: {\n ...vabs.rpcUrls,\n alchemy: {\n http: [\"https://arb-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const goerli: Chain = {\n ...vgo,\n rpcUrls: {\n ...vgo.rpcUrls,\n alchemy: {\n http: [\"https://eth-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const mainnet: Chain = {\n ...vmain,\n rpcUrls: {\n ...vmain.rpcUrls,\n alchemy: {\n http: [\"https://eth-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimism: Chain = {\n ...vop,\n rpcUrls: {\n ...vop.rpcUrls,\n alchemy: {\n http: [\"https://opt-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismGoerli: Chain = {\n ...vopg,\n rpcUrls: {\n ...vopg.rpcUrls,\n alchemy: {\n http: [\"https://opt-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismSepolia: Chain = {\n ...vops,\n rpcUrls: {\n ...vops.rpcUrls,\n alchemy: {\n http: [\"https://opt-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const sepolia: Chain = {\n ...vsep,\n rpcUrls: {\n ...vsep.rpcUrls,\n alchemy: {\n http: [\"https://eth-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const base: Chain = {\n ...vbase,\n rpcUrls: {\n ...vbase.rpcUrls,\n alchemy: {\n http: [\"https://base-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseGoerli: Chain = {\n ...vbaseg,\n rpcUrls: {\n ...vbaseg.rpcUrls,\n alchemy: {\n http: [\"https://base-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseSepolia: Chain = {\n ...vbases,\n rpcUrls: {\n ...vbases.rpcUrls,\n alchemy: {\n http: [\"https://base-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonMumbai: Chain = {\n ...vpgm,\n rpcUrls: {\n ...vpgm.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mumbai.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonAmoy: Chain = {\n ...vpga,\n rpcUrls: {\n ...vpga.rpcUrls,\n alchemy: {\n http: [\"https://polygon-amoy.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygon: Chain = {\n ...vpg,\n rpcUrls: {\n ...vpg.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const fraxtal: Chain = {\n ...vfrax,\n rpcUrls: {\n ...vfrax.rpcUrls,\n },\n};\n\nexport const fraxtalSepolia: Chain = defineChain({\n id: 2523,\n name: \"Fraxtal Sepolia\",\n nativeCurrency: { name: \"Frax Ether\", symbol: \"frxETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://rpc.testnet-sepolia.frax.com\"],\n },\n },\n});\n\nexport const zora: Chain = {\n ...vzora,\n rpcUrls: {\n ...vzora.rpcUrls,\n },\n};\n\nexport const zoraSepolia: Chain = {\n ...vzoras,\n rpcUrls: {\n ...vzoras.rpcUrls,\n },\n};\n"]}
1
+ {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":";;;AAEA,+BAAmC;AACnC,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ACtD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,6CAA6C,CAAC;SACtD;QACD,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,6CAA6C,CAAC;SACtD;KACF;CACF,CAAC,CAAC;AAEU,QAAA,UAAU,GAAU,IAAA,kBAAW,EAAC;IAC3C,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,aAAa;IACtB,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC9D,OAAO,EAAE;QACP,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,6CAA6C,CAAC;SACtD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,6CAA6C,CAAC;SACtD;QACD,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,6CAA6C,CAAC;SACtD;KACF;CACF,CAAC,CAAC","sourcesContent":["import type { Chain } from \"viem\";\n\nimport { defineChain } from \"viem\";\nimport {\n arbitrum as vab,\n arbitrumGoerli as vabg,\n arbitrumSepolia as vabs,\n base as vbase,\n baseGoerli as vbaseg,\n baseSepolia as vbases,\n fraxtal as vfrax,\n goerli as vgo,\n mainnet as vmain,\n optimism as vop,\n optimismGoerli as vopg,\n optimismSepolia as vops,\n polygon as vpg,\n polygonAmoy as vpga,\n polygonMumbai as vpgm,\n sepolia as vsep,\n zora as vzora,\n zoraSepolia as vzoras,\n} from \"viem/chains\";\n\nexport type AlchemyChainConfig = {\n chain: Chain;\n rpcBaseUrl: string;\n};\n\n/**\n * Defines an Alchemy chain configuration by adding an Alchemy-specific RPC base URL to the chain's RPC URLs.\n *\n * @example\n * ```ts\n * import { defineAlchemyChain } from \"@account-kit/infra\";\n * import { sepolia } from \"viem/chains\";\n *\n * const chain = defineAlchemyChain({\n * chain: sepolia,\n * rpcBaseUrl: \"https://eth-sepolia.g.alchemy.com/v2\"\n * });\n * ```\n *\n * @param {AlchemyChainConfig} params The parameters for defining the Alchemy chain\n * @param {Chain} params.chain The original chain configuration\n * @param {string} params.rpcBaseUrl The Alchemy-specific RPC base URL\n * @returns {Chain} The updated chain configuration with the Alchemy RPC URL added\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\nexport const arbitrum: Chain = {\n ...vab,\n rpcUrls: {\n ...vab.rpcUrls,\n alchemy: {\n http: [\"https://arb-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumGoerli: Chain = {\n ...vabg,\n rpcUrls: {\n ...vabg.rpcUrls,\n alchemy: {\n http: [\"https://arb-goerli.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumSepolia: Chain = {\n ...vabs,\n rpcUrls: {\n ...vabs.rpcUrls,\n alchemy: {\n http: [\"https://arb-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const goerli: Chain = {\n ...vgo,\n rpcUrls: {\n ...vgo.rpcUrls,\n alchemy: {\n http: [\"https://eth-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const mainnet: Chain = {\n ...vmain,\n rpcUrls: {\n ...vmain.rpcUrls,\n alchemy: {\n http: [\"https://eth-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimism: Chain = {\n ...vop,\n rpcUrls: {\n ...vop.rpcUrls,\n alchemy: {\n http: [\"https://opt-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismGoerli: Chain = {\n ...vopg,\n rpcUrls: {\n ...vopg.rpcUrls,\n alchemy: {\n http: [\"https://opt-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismSepolia: Chain = {\n ...vops,\n rpcUrls: {\n ...vops.rpcUrls,\n alchemy: {\n http: [\"https://opt-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const sepolia: Chain = {\n ...vsep,\n rpcUrls: {\n ...vsep.rpcUrls,\n alchemy: {\n http: [\"https://eth-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const base: Chain = {\n ...vbase,\n rpcUrls: {\n ...vbase.rpcUrls,\n alchemy: {\n http: [\"https://base-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseGoerli: Chain = {\n ...vbaseg,\n rpcUrls: {\n ...vbaseg.rpcUrls,\n alchemy: {\n http: [\"https://base-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseSepolia: Chain = {\n ...vbases,\n rpcUrls: {\n ...vbases.rpcUrls,\n alchemy: {\n http: [\"https://base-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonMumbai: Chain = {\n ...vpgm,\n rpcUrls: {\n ...vpgm.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mumbai.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonAmoy: Chain = {\n ...vpga,\n rpcUrls: {\n ...vpga.rpcUrls,\n alchemy: {\n http: [\"https://polygon-amoy.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygon: Chain = {\n ...vpg,\n rpcUrls: {\n ...vpg.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const fraxtal: Chain = {\n ...vfrax,\n rpcUrls: {\n ...vfrax.rpcUrls,\n },\n};\n\nexport const fraxtalSepolia: Chain = defineChain({\n id: 2523,\n name: \"Fraxtal Sepolia\",\n nativeCurrency: { name: \"Frax Ether\", symbol: \"frxETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://rpc.testnet-sepolia.frax.com\"],\n },\n },\n});\n\nexport const zora: Chain = {\n ...vzora,\n rpcUrls: {\n ...vzora.rpcUrls,\n },\n};\n\nexport const zoraSepolia: Chain = {\n ...vzoras,\n rpcUrls: {\n ...vzoras.rpcUrls,\n },\n};\n\nexport const worldChainSepolia: Chain = defineChain({\n id: 4801,\n name: \"World Chain Sepolia\",\n network: \"World Chain Sepolia\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const worldChain: Chain = defineChain({\n id: 480,\n name: \"World Chain\",\n network: \"World Chain\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccountClientFromRpc.js","sourceRoot":"","sources":["../../../../src/client/internal/smartAccountClientFromRpc.ts"],"names":[],"mappings":";;;AAAA,uCAOsB;AAEtB,sEAAuE;AACvE,kEAA6E;AAC7E,0FAA2F;AAC3F,mEAA+D;AAmB/D,SAAgB,mBAAmB,CAEjC,OAAiB;IACjB,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;AACrE,CAAC;AAJD,kDAIC;AA4CD,SAAgB,4CAA4C,CAC1D,IAAwD;IAExD,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,GACP,GAAG,IAAI,CAAC;IACT,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,IAAA,wCAAiC,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEtE,MAAM,SAAS,GAAG,IAAA,2CAAoC,EAA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S,CAAC;AACnB,CAAC;AA7DD,oGA6DC","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 CreateAlchemySmartAccountClientFromRpcClientParams<\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: CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>\n): AlchemySmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\n/**\n * Creates an AlchemySmartAccountClient using the provided RPC client configuration, including options, account, simulation settings, gas management, fee estimation, middleware and user operation signing.\n *\n * @example\n * ```ts\n * import { createAlchemySmartAccountClientFromRpcClient, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n *\n * const client = createAlchemyPublicRpcClient(...);\n * const scaClient = createAlchemySmartAccountClientFromRpcClient({\n * client,\n * ...\n * });\n * ```\n *\n * @param {CreateAlchemySmartAccountClientFromRpcClientParams} args The configuration object containing all required parameters\n * @returns {AlchemySmartAccountClient} An instance of AlchemySmartAccountClient\n */\nexport function createAlchemySmartAccountClientFromRpcClient(\n args: CreateAlchemySmartAccountClientFromRpcClientParams\n): AlchemySmartAccountClient {\n const {\n opts,\n account,\n useSimulation,\n gasManagerConfig,\n feeEstimator,\n gasEstimator,\n customMiddleware,\n signUserOperation,\n client,\n } = args;\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"]}
1
+ {"version":3,"file":"smartAccountClientFromRpc.js","sourceRoot":"","sources":["../../../../src/client/internal/smartAccountClientFromRpc.ts"],"names":[],"mappings":";;;AAAA,uCAOsB;AAEtB,sEAAuE;AACvE,kEAA6E;AAC7E,0FAA2F;AAC3F,mEAA+D;AAmB/D,SAAgB,mBAAmB,CAEjC,OAAiB;IACjB,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;AACrE,CAAC;AAJD,kDAIC;AA4CD,SAAgB,4CAA4C,CAC1D,IAAwD;IAExD,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,GACP,GAAG,IAAI,CAAC;IACT,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,IAAA,wCAAiC,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEtE,MAAM,SAAS,GAAG,IAAA,2CAAoC,EAAC;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,IAAA,+BAAwB,EAAC,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,IAAA,qCAAmB,EAAC,MAAM,CAAC;QACzD,sBAAsB,EAAE,aAAa;YACnC,CAAC,CAAC,IAAA,yDAA6B,EAAC,MAAM,CAAC;YACvC,CAAC,CAAC,SAAS;QACb,YAAY;QACZ,GAAG,CAAC,gBAAgB;YAClB,IAAA,2CAA2B,EAAC,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,gCAAc,CAAC,CAAC;IAE1B,IAAI,OAAO,IAAI,IAAA,+BAAwB,EAAC,OAAO,CAAC,EAAE,CAAC;QACjD,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AA7DD,oGA6DC","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 CreateAlchemySmartAccountClientFromRpcClientParams<\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 {CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>} args configuration for the client\n * @returns {AlchemySmartAccountClient} 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: CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>\n): AlchemySmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\n/**\n * Creates an AlchemySmartAccountClient using the provided RPC client configuration, including options, account, simulation settings, gas management, fee estimation, middleware and user operation signing.\n *\n * @example\n * ```ts\n * import { createAlchemySmartAccountClientFromRpcClient, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n *\n * const client = createAlchemyPublicRpcClient(...);\n * const scaClient = createAlchemySmartAccountClientFromRpcClient({\n * client,\n * ...\n * });\n * ```\n *\n * @param {CreateAlchemySmartAccountClientFromRpcClientParams} args The configuration object containing all required parameters\n * @returns {AlchemySmartAccountClient} An instance of AlchemySmartAccountClient\n */\nexport function createAlchemySmartAccountClientFromRpcClient(\n args: CreateAlchemySmartAccountClientFromRpcClientParams\n): AlchemySmartAccountClient {\n const {\n opts,\n account,\n useSimulation,\n gasManagerConfig,\n feeEstimator,\n gasEstimator,\n customMiddleware,\n signUserOperation,\n client,\n } = args;\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"]}
@@ -2,7 +2,7 @@ export type * from "./actions/simulateUserOperationChanges.js";
2
2
  export { simulateUserOperationChanges } from "./actions/simulateUserOperationChanges.js";
3
3
  export type * from "./actions/types.js";
4
4
  export type * from "./chains.js";
5
- export { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, zora, zoraSepolia, } from "./chains.js";
5
+ export { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, zora, zoraSepolia, worldChain, worldChainSepolia, } from "./chains.js";
6
6
  export type * from "./client/decorators/alchemyEnhancedApis.js";
7
7
  export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
8
8
  export type * from "./client/decorators/smartAccount.js";
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AlchemyProviderConfigSchema = exports.alchemyUserOperationSimulator = exports.alchemyGasManagerMiddleware = exports.alchemyFeeEstimator = exports.getAlchemyPaymasterAddress = exports.getDefaultUserOperationFeeOptions = exports.createAlchemySmartAccountClient = exports.createAlchemyPublicRpcClient = exports.isAlchemySmartAccountClient = exports.createAlchemySmartAccountClientFromExisting = exports.alchemyActions = exports.alchemyEnhancedApiActions = exports.zoraSepolia = exports.zora = exports.sepolia = exports.polygonMumbai = exports.polygonAmoy = exports.polygon = exports.optimismSepolia = exports.optimismGoerli = exports.optimism = exports.mainnet = exports.goerli = exports.fraxtalSepolia = exports.fraxtal = exports.defineAlchemyChain = exports.baseSepolia = exports.baseGoerli = exports.base = exports.arbitrumSepolia = exports.arbitrumGoerli = exports.arbitrum = exports.simulateUserOperationChanges = void 0;
3
+ exports.AlchemyProviderConfigSchema = exports.alchemyUserOperationSimulator = exports.alchemyGasManagerMiddleware = exports.alchemyFeeEstimator = exports.getAlchemyPaymasterAddress = exports.getDefaultUserOperationFeeOptions = exports.createAlchemySmartAccountClient = exports.createAlchemyPublicRpcClient = exports.isAlchemySmartAccountClient = exports.createAlchemySmartAccountClientFromExisting = exports.alchemyActions = exports.alchemyEnhancedApiActions = exports.worldChainSepolia = exports.worldChain = exports.zoraSepolia = exports.zora = exports.sepolia = exports.polygonMumbai = exports.polygonAmoy = exports.polygon = exports.optimismSepolia = exports.optimismGoerli = exports.optimism = exports.mainnet = exports.goerli = exports.fraxtalSepolia = exports.fraxtal = exports.defineAlchemyChain = exports.baseSepolia = exports.baseGoerli = exports.base = exports.arbitrumSepolia = exports.arbitrumGoerli = exports.arbitrum = exports.simulateUserOperationChanges = void 0;
4
4
  var simulateUserOperationChanges_js_1 = require("./actions/simulateUserOperationChanges.js");
5
5
  Object.defineProperty(exports, "simulateUserOperationChanges", { enumerable: true, get: function () { return simulateUserOperationChanges_js_1.simulateUserOperationChanges; } });
6
6
  var chains_js_1 = require("./chains.js");
@@ -24,6 +24,8 @@ Object.defineProperty(exports, "polygonMumbai", { enumerable: true, get: functio
24
24
  Object.defineProperty(exports, "sepolia", { enumerable: true, get: function () { return chains_js_1.sepolia; } });
25
25
  Object.defineProperty(exports, "zora", { enumerable: true, get: function () { return chains_js_1.zora; } });
26
26
  Object.defineProperty(exports, "zoraSepolia", { enumerable: true, get: function () { return chains_js_1.zoraSepolia; } });
27
+ Object.defineProperty(exports, "worldChain", { enumerable: true, get: function () { return chains_js_1.worldChain; } });
28
+ Object.defineProperty(exports, "worldChainSepolia", { enumerable: true, get: function () { return chains_js_1.worldChainSepolia; } });
27
29
  var alchemyEnhancedApis_js_1 = require("./client/decorators/alchemyEnhancedApis.js");
28
30
  Object.defineProperty(exports, "alchemyEnhancedApiActions", { enumerable: true, get: function () { return alchemyEnhancedApis_js_1.alchemyEnhancedApiActions; } });
29
31
  var smartAccount_js_1 = require("./client/decorators/smartAccount.js");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,6FAAyF;AAAhF,+IAAA,4BAA4B,OAAA;AAGrC,yCAqBqB;AApBnB,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,iGAAA,IAAI,OAAA;AACJ,uGAAA,UAAU,OAAA;AACV,wGAAA,WAAW,OAAA;AACX,+GAAA,kBAAkB,OAAA;AAClB,oGAAA,OAAO,OAAA;AACP,2GAAA,cAAc,OAAA;AACd,mGAAA,MAAM,OAAA;AACN,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,oGAAA,OAAO,OAAA;AACP,wGAAA,WAAW,OAAA;AACX,0GAAA,aAAa,OAAA;AACb,oGAAA,OAAO,OAAA;AACP,iGAAA,IAAI,OAAA;AACJ,wGAAA,WAAW,OAAA;AAGb,qFAAuF;AAA9E,mIAAA,yBAAyB,OAAA;AAElC,uEAAqE;AAA5D,iHAAA,cAAc,OAAA;AACvB,+FAA6J;AAApJ,2JAAA,4CAA4C,OAA+C;AACpG,0FAAsF;AAA7E,6IAAA,2BAA2B,OAAA;AAEpC,sDAAqE;AAA5D,4HAAA,4BAA4B,OAAA;AAErC,wEAAiF;AAAxE,wIAAA,+BAA+B,OAAA;AAExC,6CAAkE;AAAzD,gIAAA,iCAAiC,OAAA;AAC1C,mDAA8D;AAArD,4HAAA,0BAA0B,OAAA;AACnC,gEAAmE;AAA1D,sHAAA,mBAAmB,OAAA;AAE5B,4DAAyE;AAAhE,4HAAA,2BAA2B,OAAA;AACpC,oFAAuF;AAA9E,0IAAA,6BAA6B,OAAA;AAEtC,yCAA0D;AAAjD,wHAAA,2BAA2B,OAAA","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport type * from \"./chains.js\";\nexport {\n arbitrum,\n arbitrumGoerli,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n defineAlchemyChain,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n zora,\n zoraSepolia,\n} from \"./chains.js\";\nexport type * from \"./client/decorators/alchemyEnhancedApis.js\";\nexport { alchemyEnhancedApiActions } from \"./client/decorators/alchemyEnhancedApis.js\";\nexport type * from \"./client/decorators/smartAccount.js\";\nexport { alchemyActions } from \"./client/decorators/smartAccount.js\";\nexport { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from \"./client/internal/smartAccountClientFromRpc.js\";\nexport { isAlchemySmartAccountClient } from \"./client/isAlchemySmartAccountClient.js\";\nexport type * from \"./client/rpcClient.js\";\nexport { createAlchemyPublicRpcClient } from \"./client/rpcClient.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport { createAlchemySmartAccountClient } from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport { getDefaultUserOperationFeeOptions } from \"./defaults.js\";\nexport { getAlchemyPaymasterAddress } from \"./gas-manager.js\";\nexport { alchemyFeeEstimator } from \"./middleware/feeEstimator.js\";\nexport type * from \"./middleware/gasManager.js\";\nexport { alchemyGasManagerMiddleware } from \"./middleware/gasManager.js\";\nexport { alchemyUserOperationSimulator } from \"./middleware/userOperationSimulator.js\";\nexport type * from \"./schema.js\";\nexport { AlchemyProviderConfigSchema } from \"./schema.js\";\nexport type { AlchemyProviderConfig } from \"./type.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,6FAAyF;AAAhF,+IAAA,4BAA4B,OAAA;AAGrC,yCAuBqB;AAtBnB,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,iGAAA,IAAI,OAAA;AACJ,uGAAA,UAAU,OAAA;AACV,wGAAA,WAAW,OAAA;AACX,+GAAA,kBAAkB,OAAA;AAClB,oGAAA,OAAO,OAAA;AACP,2GAAA,cAAc,OAAA;AACd,mGAAA,MAAM,OAAA;AACN,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,oGAAA,OAAO,OAAA;AACP,wGAAA,WAAW,OAAA;AACX,0GAAA,aAAa,OAAA;AACb,oGAAA,OAAO,OAAA;AACP,iGAAA,IAAI,OAAA;AACJ,wGAAA,WAAW,OAAA;AACX,uGAAA,UAAU,OAAA;AACV,8GAAA,iBAAiB,OAAA;AAGnB,qFAAuF;AAA9E,mIAAA,yBAAyB,OAAA;AAElC,uEAAqE;AAA5D,iHAAA,cAAc,OAAA;AACvB,+FAA6J;AAApJ,2JAAA,4CAA4C,OAA+C;AACpG,0FAAsF;AAA7E,6IAAA,2BAA2B,OAAA;AAEpC,sDAAqE;AAA5D,4HAAA,4BAA4B,OAAA;AAErC,wEAAiF;AAAxE,wIAAA,+BAA+B,OAAA;AAExC,6CAAkE;AAAzD,gIAAA,iCAAiC,OAAA;AAC1C,mDAA8D;AAArD,4HAAA,0BAA0B,OAAA;AACnC,gEAAmE;AAA1D,sHAAA,mBAAmB,OAAA;AAE5B,4DAAyE;AAAhE,4HAAA,2BAA2B,OAAA;AACpC,oFAAuF;AAA9E,0IAAA,6BAA6B,OAAA;AAEtC,yCAA0D;AAAjD,wHAAA,2BAA2B,OAAA","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport type * from \"./chains.js\";\nexport {\n arbitrum,\n arbitrumGoerli,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n defineAlchemyChain,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n zora,\n zoraSepolia,\n worldChain,\n worldChainSepolia,\n} from \"./chains.js\";\nexport type * from \"./client/decorators/alchemyEnhancedApis.js\";\nexport { alchemyEnhancedApiActions } from \"./client/decorators/alchemyEnhancedApis.js\";\nexport type * from \"./client/decorators/smartAccount.js\";\nexport { alchemyActions } from \"./client/decorators/smartAccount.js\";\nexport { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from \"./client/internal/smartAccountClientFromRpc.js\";\nexport { isAlchemySmartAccountClient } from \"./client/isAlchemySmartAccountClient.js\";\nexport type * from \"./client/rpcClient.js\";\nexport { createAlchemyPublicRpcClient } from \"./client/rpcClient.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport { createAlchemySmartAccountClient } from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport { getDefaultUserOperationFeeOptions } from \"./defaults.js\";\nexport { getAlchemyPaymasterAddress } from \"./gas-manager.js\";\nexport { alchemyFeeEstimator } from \"./middleware/feeEstimator.js\";\nexport type * from \"./middleware/gasManager.js\";\nexport { alchemyGasManagerMiddleware } from \"./middleware/gasManager.js\";\nexport { alchemyUserOperationSimulator } from \"./middleware/userOperationSimulator.js\";\nexport type * from \"./schema.js\";\nexport { AlchemyProviderConfigSchema } from \"./schema.js\";\nexport type { AlchemyProviderConfig } from \"./type.js\";\n"]}
@@ -5,11 +5,16 @@ const core_1 = require("@aa-sdk/core");
5
5
  const viem_1 = require("viem");
6
6
  const gas_manager_js_1 = require("../gas-manager.js");
7
7
  const feeEstimator_js_1 = require("./feeEstimator.js");
8
- const dummyPaymasterAndData = (client, config) => () => {
8
+ const dummyPaymasterAndData = (client, config) => async (uo) => {
9
9
  const paymaster = config.paymasterAddress ?? (0, gas_manager_js_1.getAlchemyPaymasterAddress)(client.chain);
10
10
  const paymasterData = config.dummyData ??
11
11
  "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
12
- return (0, viem_1.concat)([paymaster, paymasterData]);
12
+ return {
13
+ ...uo,
14
+ paymaster,
15
+ paymasterData,
16
+ paymasterAndData: (0, viem_1.concat)([paymaster, paymasterData]),
17
+ };
13
18
  };
14
19
  function alchemyGasManagerMiddleware(client, config) {
15
20
  const gasEstimationOptions = config.gasEstimationOptions;
@@ -56,9 +61,9 @@ function alchemyGasManagerMiddleware(client, config) {
56
61
  maxPriorityFeePerGas,
57
62
  };
58
63
  },
59
- paymasterAndData: disableGasEstimation
64
+ ...(disableGasEstimation
60
65
  ? requestPaymasterAndData(client, config)
61
- : requestGasAndPaymasterData(client, config),
66
+ : requestGasAndPaymasterData(client, config)),
62
67
  };
63
68
  }
64
69
  exports.alchemyGasManagerMiddleware = alchemyGasManagerMiddleware;
@@ -1 +1 @@
1
- {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":";;;AAUA,uCAQsB;AACtB,+BAAwD;AAExD,sDAA+D;AAC/D,uDAAwD;AAoIxD,MAAM,qBAAqB,GACzB,CACE,MAAS,EACT,MAA+B,EAC/B,EAAE,CACJ,GAAG,EAAE;IACH,MAAM,SAAS,GACb,MAAM,CAAC,gBAAgB,IAAI,IAAA,2CAA0B,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,MAAM,aAAa,GACjB,MAAM,CAAC,SAAS;QAChB,sMAAsM,CAAC;IAEzM,OAAO,IAAA,aAAM,EAAC,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC;AAUJ,SAAgB,2BAA2B,CACzC,MAAS,EACT,MAA+B;IAK/B,MAAM,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC;IACzD,MAAM,oBAAoB,GACxB,oBAAoB,EAAE,oBAAoB,IAAI,KAAK,CAAC;IACtD,MAAM,qBAAqB,GACzB,oBAAoB,EAAE,qBAAqB,IAAI,IAAA,qCAAmB,EAAC,MAAM,CAAC,CAAC;IAC7E,MAAM,oBAAoB,GACxB,oBAAoB,EAAE,oBAAoB;QAC1C,IAAA,0BAAmB,EAAI,MAAM,CAAC,CAAC;IAEjC,OAAO;QACL,YAAY,EAAE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EAAE,aAAa,CAAC,SAAS;wBACvC,SAAS;qBACV;iBACF;aACF,CAAC,CAAC;YAEH,OAAO;gBACL,GAAG,MAAM;gBACT,GAAG,MAAM;aACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAWD,MAAM,uBAAuB,GAGqB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACrE,qBAAqB,EAAE,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC;IAC5D,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YAClC,MAAM,EAAE,iCAAiC;YACzC,MAAM,EAAE;gBACN;oBACE,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;oBAC3C,aAAa,EAAE,IAAA,kBAAW,EAAC,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAAC;iBAC5D;aACF;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,MAAM;YACT,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type {\n Address,\n ClientMiddlewareConfig,\n ClientMiddlewareFn,\n EntryPointVersion,\n Multiplier,\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport {\n bypassPaymasterAndDataEmptyHex,\n deepHexlify,\n defaultGasEstimator,\n filterUndefined,\n isBigNumberish,\n isMultiplier,\n resolveProperties,\n} from \"@aa-sdk/core\";\nimport { concat, fromHex, isHex, type Hex } from \"viem\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\nimport { getAlchemyPaymasterAddress } from \"../gas-manager.js\";\nimport { alchemyFeeEstimator } from \"./feeEstimator.js\";\n\n/**\n * overrides value for [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Partial<\n {\n maxFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxFeePerGas\"]\n | Multiplier;\n maxPriorityFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxPriorityFeePerGas\"]\n | Multiplier;\n callGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"callGasLimit\"]\n | Multiplier;\n verificationGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"verificationGasLimit\"]\n | Multiplier;\n preVerificationGas:\n | UserOperationRequest<TEntryPointVersion>[\"preVerificationGas\"]\n | Multiplier;\n } & TEntryPointVersion extends \"0.7.0\"\n ? {\n paymasterVerificationGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterVerificationGasLimit\"]\n | Multiplier;\n paymasterPostOpGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterPostOpGasLimit\"]\n | Multiplier;\n }\n : {}\n>;\n\n/**\n * [`alchemy-requestpaymasteranddata`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? {\n paymasterAndData: UserOperationRequest<\"0.6.0\">[\"paymasterAndData\"];\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? Pick<UserOperationRequest<\"0.7.0\">, \"paymaster\" | \"paymasterData\">\n : {};\n\n/**\n * [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Pick<\n UserOperationRequest,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n | \"maxFeePerGas\"\n | \"maxPriorityFeePerGas\"\n> &\n RequestPaymasterAndDataResponse<TEntryPointVersion>;\n\n/**\n * Alchemy gas manager configuration with gas policy id and optional gas estimation options\n *\n * To create a Gas Manager Policy, go to the [gas manager](https://dashboard.alchemy.com/gas-manager?a=embedded-accounts-get-started)\n * page of the Alchemy dashboard and click the “Create new policy” button.\n */\nexport interface AlchemyGasManagerConfig {\n /**\n * the policy id of the gas manager you want to use.\n *\n */\n policyId: string;\n /**\n * optional option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\n gasEstimationOptions?: AlchemyGasEstimationOptions;\n /**\n * paymaster address to use for the gas estimation.\n * If not provided, the default paymaster address for the chain will be used.\n *\n */\n paymasterAddress?: Address;\n /**\n * dummy paymaster data to use for the gas estimation.\n *\n */\n dummyData?: Hex;\n}\n\n/**\n * Alchemy gas manager configuration option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\nexport interface AlchemyGasEstimationOptions {\n /**\n * disable gas estimation and fallback to the default gas estimation.\n *\n */\n disableGasEstimation: boolean;\n /**\n * optional fallback gas estimator to use when gas estimation is disabled.\n *\n */\n fallbackGasEstimator?: ClientMiddlewareFn;\n /**\n * optional fallback fee estimator to use when gas estimation is disabled.\n *\n */\n fallbackFeeDataGetter?: ClientMiddlewareFn;\n}\n\n/**\n * Dummy paymaster and data middleware for the alchemy gas manager\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the dummyPaymasterAndData middleware for Alchemy gas manager\n */\nconst dummyPaymasterAndData =\n <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n ) =>\n () => {\n const paymaster =\n config.paymasterAddress ?? getAlchemyPaymasterAddress(client.chain);\n const paymasterData =\n config.dummyData ??\n \"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return concat([paymaster, paymasterData]); // or you can also return { paymaster, paymasterData }\n };\n\n/**\n * Alchemy gas manager middleware used as the paymaster middleware overrides param to the client middleware config\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager\n */\nexport function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): Pick<\n ClientMiddlewareConfig,\n \"paymasterAndData\" | \"feeEstimator\" | \"gasEstimator\"\n> {\n const gasEstimationOptions = config.gasEstimationOptions;\n const disableGasEstimation =\n gasEstimationOptions?.disableGasEstimation ?? false;\n const fallbackFeeDataGetter =\n gasEstimationOptions?.fallbackFeeDataGetter ?? alchemyFeeEstimator(client);\n const fallbackGasEstimator =\n gasEstimationOptions?.fallbackGasEstimator ??\n defaultGasEstimator<C>(client);\n\n return {\n gasEstimator: disableGasEstimation\n ? fallbackGasEstimator\n : async (struct, { overrides, account, feeOptions }) => {\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n return {\n ...struct,\n ...(await fallbackGasEstimator(struct, {\n overrides,\n account,\n feeOptions,\n client,\n })),\n };\n }\n\n // essentially noop, because the gas estimation will happen in the backend\n return struct;\n },\n feeEstimator: disableGasEstimation\n ? fallbackFeeDataGetter\n : async (struct, { overrides, account, feeOptions }) => {\n let maxFeePerGas = await struct.maxFeePerGas;\n let maxPriorityFeePerGas = await struct.maxPriorityFeePerGas;\n\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n const result = await fallbackFeeDataGetter(struct, {\n overrides,\n feeOptions,\n account,\n client,\n });\n maxFeePerGas = (await result.maxFeePerGas) ?? maxFeePerGas;\n maxPriorityFeePerGas =\n (await result.maxPriorityFeePerGas) ?? maxPriorityFeePerGas;\n }\n\n return {\n ...struct,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n },\n paymasterAndData: disableGasEstimation\n ? requestPaymasterAndData(client, config)\n : requestGasAndPaymasterData(client, config),\n };\n}\n\n/**\n * Utility function to override a field in the user operation request with the overrides or fee options\n *\n * @template {EntryPointVersion} TEntryPointVersion\n * @param field the field to override\n * @param overrides the overrides object\n * @param feeOptions the fee options object from the client\n * @param userOperation the user operation request\n * @returns the overridden field value\n */\nconst overrideField = <\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n field: keyof UserOperationFeeOptions<TEntryPointVersion>,\n overrides: UserOperationOverrides<TEntryPointVersion> | undefined,\n feeOptions: UserOperationFeeOptions<TEntryPointVersion> | undefined,\n userOperation: UserOperationRequest<TEntryPointVersion>\n): Hex | Multiplier | undefined => {\n let _field = field as keyof UserOperationOverrides<TEntryPointVersion>;\n\n if (overrides?.[_field] != null) {\n // one-off absolute override\n if (isBigNumberish(overrides[_field])) {\n return deepHexlify(overrides[_field]);\n }\n // one-off multiplier overrides\n else {\n return {\n multiplier: Number((overrides[_field] as Multiplier).multiplier),\n };\n }\n }\n\n // provider level fee options with multiplier\n if (isMultiplier(feeOptions?.[field])) {\n return {\n multiplier: Number((feeOptions![field] as Multiplier).multiplier),\n };\n }\n\n const userOpField =\n userOperation[field as keyof UserOperationRequest<TEntryPointVersion>];\n if (isHex(userOpField) && fromHex(userOpField as Hex, \"bigint\") > 0n) {\n return userOpField;\n }\n return undefined;\n};\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestGasAndPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager\n */\nfunction requestGasAndPaymasterData<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): ClientMiddlewareConfig[\"paymasterAndData\"] {\n return {\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n\n paymasterAndData: async (\n struct,\n { overrides: overrides_, feeOptions, account }\n ) => {\n const userOperation: UserOperationRequest = deepHexlify(\n await resolveProperties(struct)\n );\n\n const overrides: RequestGasAndPaymasterAndDataOverrides = filterUndefined(\n {\n maxFeePerGas: overrideField(\n \"maxFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n maxPriorityFeePerGas: overrideField(\n \"maxPriorityFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n callGasLimit: overrideField(\n \"callGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n verificationGasLimit: overrideField(\n \"verificationGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n preVerificationGas: overrideField(\n \"preVerificationGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n }\n );\n\n if (account.getEntryPoint().version === \"0.7.0\") {\n const paymasterVerificationGasLimit = overrideField<\"0.7.0\">(\n \"paymasterVerificationGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterVerificationGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterVerificationGasLimit = paymasterVerificationGasLimit;\n }\n\n const paymasterPostOpGasLimit = overrideField<\"0.7.0\">(\n \"paymasterPostOpGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterPostOpGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterPostOpGasLimit = paymasterPostOpGasLimit;\n }\n }\n\n const result = await client.request({\n method: \"alchemy_requestGasAndPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation,\n dummySignature: userOperation.signature,\n overrides,\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n };\n}\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * with gas estimation disabled.\n *\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager with gas estimation disabled\n */\nconst requestPaymasterAndData: <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n) => ClientMiddlewareConfig[\"paymasterAndData\"] = (client, config) => ({\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n paymasterAndData: async (struct, { account }) => {\n const result = await client.request({\n method: \"alchemy_requestPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation: deepHexlify(await resolveProperties(struct)),\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n});\n"]}
1
+ {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":";;;AAUA,uCAQsB;AACtB,+BAAwD;AAExD,sDAA+D;AAC/D,uDAAwD;AAsIxD,MAAM,qBAAqB,GACzB,CACE,MAAS,EACT,MAA+B,EACX,EAAE,CACxB,KAAK,EAAE,EAAE,EAAE,EAAE;IACX,MAAM,SAAS,GACb,MAAM,CAAC,gBAAgB,IAAI,IAAA,2CAA0B,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,MAAM,aAAa,GACjB,MAAM,CAAC,SAAS;QAChB,sMAAsM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AAC;QAEH,OAAO;YACL,GAAG,MAAM;YACT,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type {\n Address,\n ClientMiddlewareConfig,\n ClientMiddlewareFn,\n EntryPointVersion,\n Multiplier,\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport {\n bypassPaymasterAndDataEmptyHex,\n deepHexlify,\n defaultGasEstimator,\n filterUndefined,\n isBigNumberish,\n isMultiplier,\n resolveProperties,\n} from \"@aa-sdk/core\";\nimport { concat, fromHex, isHex, type Hex } from \"viem\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\nimport { getAlchemyPaymasterAddress } from \"../gas-manager.js\";\nimport { alchemyFeeEstimator } from \"./feeEstimator.js\";\n\n/**\n * overrides value for [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Partial<\n {\n maxFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxFeePerGas\"]\n | Multiplier;\n maxPriorityFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxPriorityFeePerGas\"]\n | Multiplier;\n callGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"callGasLimit\"]\n | Multiplier;\n verificationGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"verificationGasLimit\"]\n | Multiplier;\n preVerificationGas:\n | UserOperationRequest<TEntryPointVersion>[\"preVerificationGas\"]\n | Multiplier;\n } & TEntryPointVersion extends \"0.7.0\"\n ? {\n paymasterVerificationGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterVerificationGasLimit\"]\n | Multiplier;\n paymasterPostOpGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterPostOpGasLimit\"]\n | Multiplier;\n }\n : {}\n>;\n\n/**\n * [`alchemy-requestpaymasteranddata`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? {\n paymasterAndData: UserOperationRequest<\"0.6.0\">[\"paymasterAndData\"];\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? Pick<UserOperationRequest<\"0.7.0\">, \"paymaster\" | \"paymasterData\">\n : {};\n\n/**\n * [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Pick<\n UserOperationRequest,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n | \"maxFeePerGas\"\n | \"maxPriorityFeePerGas\"\n> &\n RequestPaymasterAndDataResponse<TEntryPointVersion>;\n\n/**\n * Alchemy gas manager configuration with gas policy id and optional gas estimation options\n *\n * To create a Gas Manager Policy, go to the [gas manager](https://dashboard.alchemy.com/gas-manager?a=embedded-accounts-get-started)\n * page of the Alchemy dashboard and click the “Create new policy” button.\n */\nexport interface AlchemyGasManagerConfig {\n /**\n * the policy id of the gas manager you want to use.\n *\n */\n policyId: string;\n /**\n * optional option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\n gasEstimationOptions?: AlchemyGasEstimationOptions;\n /**\n * paymaster address to use for the gas estimation.\n * If not provided, the default paymaster address for the chain will be used.\n *\n */\n paymasterAddress?: Address;\n /**\n * dummy paymaster data to use for the gas estimation.\n *\n */\n dummyData?: Hex;\n}\n\n/**\n * Alchemy gas manager configuration option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\nexport interface AlchemyGasEstimationOptions {\n /**\n * disable gas estimation and fallback to the default gas estimation.\n *\n */\n disableGasEstimation: boolean;\n /**\n * optional fallback gas estimator to use when gas estimation is disabled.\n *\n */\n fallbackGasEstimator?: ClientMiddlewareFn;\n /**\n * optional fallback fee estimator to use when gas estimation is disabled.\n *\n */\n fallbackFeeDataGetter?: ClientMiddlewareFn;\n}\n\n/**\n * Dummy paymaster and data middleware for the alchemy gas manager\n *\n * NOTE: right now, this only really works for 0.6.0 unless you pass in overrides in the config for 0.7.0\n *\n * @template {ClientWithAlchemyMethods} C\n * @param {ClientWithAlchemyMethods} client client with alchemy methods\n * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration\n * @returns {() => Hex} the dummyPaymasterAndData middleware for Alchemy gas manager\n */\nconst dummyPaymasterAndData =\n <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n ): ClientMiddlewareFn =>\n async (uo) => {\n const paymaster =\n config.paymasterAddress ?? getAlchemyPaymasterAddress(client.chain);\n const paymasterData =\n config.dummyData ??\n \"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return {\n ...uo,\n paymaster,\n paymasterData,\n paymasterAndData: concat([paymaster, paymasterData]),\n };\n };\n\n/**\n * Alchemy gas manager middleware used as the paymaster middleware overrides param to the client middleware config\n *\n * @template {ClientWithAlchemyMethods} C\n * @param {ClientWithAlchemyMethods} client client with alchemy methods\n * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration\n * @returns {Pick<ClientMiddlewareConfig,\"paymasterAndData\" | \"feeEstimator\" | \"gasEstimator\">} the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager\n */\nexport function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): Pick<\n ClientMiddlewareConfig,\n \"paymasterAndData\" | \"feeEstimator\" | \"gasEstimator\"\n> {\n const gasEstimationOptions = config.gasEstimationOptions;\n const disableGasEstimation =\n gasEstimationOptions?.disableGasEstimation ?? false;\n const fallbackFeeDataGetter =\n gasEstimationOptions?.fallbackFeeDataGetter ?? alchemyFeeEstimator(client);\n const fallbackGasEstimator =\n gasEstimationOptions?.fallbackGasEstimator ??\n defaultGasEstimator<C>(client);\n\n return {\n gasEstimator: disableGasEstimation\n ? fallbackGasEstimator\n : async (struct, { overrides, account, feeOptions }) => {\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n return {\n ...struct,\n ...(await fallbackGasEstimator(struct, {\n overrides,\n account,\n feeOptions,\n client,\n })),\n };\n }\n\n // essentially noop, because the gas estimation will happen in the backend\n return struct;\n },\n feeEstimator: disableGasEstimation\n ? fallbackFeeDataGetter\n : async (struct, { overrides, account, feeOptions }) => {\n let maxFeePerGas = await struct.maxFeePerGas;\n let maxPriorityFeePerGas = await struct.maxPriorityFeePerGas;\n\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n const result = await fallbackFeeDataGetter(struct, {\n overrides,\n feeOptions,\n account,\n client,\n });\n maxFeePerGas = (await result.maxFeePerGas) ?? maxFeePerGas;\n maxPriorityFeePerGas =\n (await result.maxPriorityFeePerGas) ?? maxPriorityFeePerGas;\n }\n\n return {\n ...struct,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n },\n ...(disableGasEstimation\n ? requestPaymasterAndData(client, config)\n : requestGasAndPaymasterData(client, config)),\n };\n}\n\n/**\n * Utility function to override a field in the user operation request with the overrides or fee options\n *\n * @template {EntryPointVersion} TEntryPointVersion\n * @param {keyof UserOperationFeeOptions<TEntryPointVersion>} field the field to override\n * @param {UserOperationOverrides<TEntryPointVersion> | undefined} overrides the overrides object\n * @param {UserOperationFeeOptions<TEntryPointVersion> | undefined} feeOptions the fee options object from the client\n * @param {UserOperationRequest<TEntryPointVersion>} userOperation the user operation request\n * @returns {Hex | Multiplier | undefine} the overridden field value\n */\nconst overrideField = <\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n field: keyof UserOperationFeeOptions<TEntryPointVersion>,\n overrides: UserOperationOverrides<TEntryPointVersion> | undefined,\n feeOptions: UserOperationFeeOptions<TEntryPointVersion> | undefined,\n userOperation: UserOperationRequest<TEntryPointVersion>\n): Hex | Multiplier | undefined => {\n let _field = field as keyof UserOperationOverrides<TEntryPointVersion>;\n\n if (overrides?.[_field] != null) {\n // one-off absolute override\n if (isBigNumberish(overrides[_field])) {\n return deepHexlify(overrides[_field]);\n }\n // one-off multiplier overrides\n else {\n return {\n multiplier: Number((overrides[_field] as Multiplier).multiplier),\n };\n }\n }\n\n // provider level fee options with multiplier\n if (isMultiplier(feeOptions?.[field])) {\n return {\n multiplier: Number((feeOptions![field] as Multiplier).multiplier),\n };\n }\n\n const userOpField =\n userOperation[field as keyof UserOperationRequest<TEntryPointVersion>];\n if (isHex(userOpField) && fromHex(userOpField as Hex, \"bigint\") > 0n) {\n return userOpField;\n }\n return undefined;\n};\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestGasAndPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {ClientWithAlchemyMethods} C\n * @param {ClientWithAlchemyMethods} client client with alchemy methods\n * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration\n * @returns {ClientMiddlewareConfig[\"paymasterAndData\"]} the paymasterAndData middleware for Alchemy gas manager\n */\nfunction requestGasAndPaymasterData<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n return {\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n paymasterAndData: async (\n struct,\n { overrides: overrides_, feeOptions, account }\n ) => {\n const userOperation: UserOperationRequest = deepHexlify(\n await resolveProperties(struct)\n );\n\n const overrides: RequestGasAndPaymasterAndDataOverrides = filterUndefined(\n {\n maxFeePerGas: overrideField(\n \"maxFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n maxPriorityFeePerGas: overrideField(\n \"maxPriorityFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n callGasLimit: overrideField(\n \"callGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n verificationGasLimit: overrideField(\n \"verificationGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n preVerificationGas: overrideField(\n \"preVerificationGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n }\n );\n\n if (account.getEntryPoint().version === \"0.7.0\") {\n const paymasterVerificationGasLimit = overrideField<\"0.7.0\">(\n \"paymasterVerificationGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterVerificationGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterVerificationGasLimit = paymasterVerificationGasLimit;\n }\n\n const paymasterPostOpGasLimit = overrideField<\"0.7.0\">(\n \"paymasterPostOpGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterPostOpGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterPostOpGasLimit = paymasterPostOpGasLimit;\n }\n }\n\n const result = await client.request({\n method: \"alchemy_requestGasAndPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation,\n dummySignature: userOperation.signature,\n overrides,\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n };\n}\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * with gas estimation disabled.\n *\n * @param {ClientWithAlchemyMethods} client client with alchemy methods\n * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration\n * @returns {ClientMiddlewareConfig[\"paymasterAndData\"]} the paymasterAndData middleware for Alchemy gas manager with gas estimation disabled\n */\nconst requestPaymasterAndData: <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n) => Pick<\n ClientMiddlewareConfig,\n \"dummyPaymasterAndData\" | \"paymasterAndData\"\n> = (client, config) => ({\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n paymasterAndData: async (struct, { account }) => {\n const result = await client.request({\n method: \"alchemy_requestPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation: deepHexlify(await resolveProperties(struct)),\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n});\n"]}
@@ -1,3 +1,3 @@
1
- import { type ClientMiddlewareFn } from "@aa-sdk/core";
1
+ import { type ClientMiddlewareFn, type UserOperationContext } from "@aa-sdk/core";
2
2
  import type { ClientWithAlchemyMethods } from "../client/types";
3
- export declare function alchemyUserOperationSimulator<C extends ClientWithAlchemyMethods>(client: C): ClientMiddlewareFn;
3
+ export declare function alchemyUserOperationSimulator<C extends ClientWithAlchemyMethods, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: C): ClientMiddlewareFn<TContext>;
@@ -1 +1 @@
1
- {"version":3,"file":"userOperationSimulator.js","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":";;;AAAA,uCAIsB;AAsBtB,SAAgB,6BAA6B,CAE3C,MAAS;IACT,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACvC,MAAM,EAAE,2CAA2C;YACnD,MAAM,EAAE;gBACN,IAAA,kBAAW,EAAC,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAAC;gBAC5C,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;aAChC;SACF,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAlBD,sEAkBC","sourcesContent":["import {\n deepHexlify,\n resolveProperties,\n type ClientMiddlewareFn,\n} from \"@aa-sdk/core\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\n\n/**\n * A middleware function to be used during simulation of user operations which leverages Alchemy's RPC uo simulation method.\n *\n * @example\n * ```ts\n * import { alchemyUserOperationSimulator, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createAlchemyPublicRpcClient(...);\n * const client = createSmartAccountClient({\n * userOperationSimulator: alchemyUserOperationSimulator(bundlerClient),\n * ...otherParams\n * });\n * ```\n *\n * @template C The client object with Alchemy methods\n * @param {C} client The client object with Alchemy methods\n * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations\n */\nexport function alchemyUserOperationSimulator<\n C extends ClientWithAlchemyMethods\n>(client: C): ClientMiddlewareFn {\n return async (struct, { account }) => {\n const uoSimResult = await client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [\n deepHexlify(await resolveProperties(struct)),\n account.getEntryPoint().address,\n ],\n });\n\n if (uoSimResult.error) {\n throw new Error(uoSimResult.error.message);\n }\n\n return struct;\n };\n}\n"]}
1
+ {"version":3,"file":"userOperationSimulator.js","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":";;;AAAA,uCAKsB;AAsBtB,SAAgB,6BAA6B,CAK3C,MAAS;IACT,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACvC,MAAM,EAAE,2CAA2C;YACnD,MAAM,EAAE;gBACN,IAAA,kBAAW,EAAC,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAAC;gBAC5C,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;aAChC;SACF,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AArBD,sEAqBC","sourcesContent":["import {\n deepHexlify,\n resolveProperties,\n type ClientMiddlewareFn,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\n\n/**\n * A middleware function to be used during simulation of user operations which leverages Alchemy's RPC uo simulation method.\n *\n * @example\n * ```ts\n * import { alchemyUserOperationSimulator, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createAlchemyPublicRpcClient(...);\n * const client = createSmartAccountClient({\n * userOperationSimulator: alchemyUserOperationSimulator(bundlerClient),\n * ...otherParams\n * });\n * ```\n *\n * @template C The client object with Alchemy methods\n * @param {C} client The client object with Alchemy methods\n * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations\n */\nexport function alchemyUserOperationSimulator<\n C extends ClientWithAlchemyMethods,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(client: C): ClientMiddlewareFn<TContext> {\n return async (struct, { account }) => {\n const uoSimResult = await client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [\n deepHexlify(await resolveProperties(struct)),\n account.getEntryPoint().address,\n ],\n });\n\n if (uoSimResult.error) {\n throw new Error(uoSimResult.error.message);\n }\n\n return struct;\n };\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.0-alpha.5";
1
+ export declare const VERSION = "4.0.0-alpha.6";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "4.0.0-alpha.5";
4
+ exports.VERSION = "4.0.0-alpha.6";
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +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.5\";\n"]}
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.6\";\n"]}
@@ -26,3 +26,5 @@ export declare const fraxtal: Chain;
26
26
  export declare const fraxtalSepolia: Chain;
27
27
  export declare const zora: Chain;
28
28
  export declare const zoraSepolia: Chain;
29
+ export declare const worldChainSepolia: Chain;
30
+ export declare const worldChain: Chain;
@@ -174,4 +174,38 @@ export const zoraSepolia = {
174
174
  ...vzoras.rpcUrls,
175
175
  },
176
176
  };
177
+ export const worldChainSepolia = defineChain({
178
+ id: 4801,
179
+ name: "World Chain Sepolia",
180
+ network: "World Chain Sepolia",
181
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
182
+ rpcUrls: {
183
+ default: {
184
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
185
+ },
186
+ public: {
187
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
188
+ },
189
+ alchemy: {
190
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
191
+ },
192
+ },
193
+ });
194
+ export const worldChain = defineChain({
195
+ id: 480,
196
+ name: "World Chain",
197
+ network: "World Chain",
198
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
199
+ rpcUrls: {
200
+ default: {
201
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
202
+ },
203
+ public: {
204
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
205
+ },
206
+ alchemy: {
207
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
208
+ },
209
+ },
210
+ });
177
211
  //# sourceMappingURL=chains.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EACL,QAAQ,IAAI,GAAG,EACf,cAAc,IAAI,IAAI,EACtB,eAAe,IAAI,IAAI,EACvB,IAAI,IAAI,KAAK,EACb,UAAU,IAAI,MAAM,EACpB,WAAW,IAAI,MAAM,EACrB,OAAO,IAAI,KAAK,EAChB,MAAM,IAAI,GAAG,EACb,OAAO,IAAI,KAAK,EAChB,QAAQ,IAAI,GAAG,EACf,cAAc,IAAI,IAAI,EACtB,eAAe,IAAI,IAAI,EACvB,OAAO,IAAI,GAAG,EACd,WAAW,IAAI,IAAI,EACnB,aAAa,IAAI,IAAI,EACrB,OAAO,IAAI,IAAI,EACf,IAAI,IAAI,KAAK,EACb,WAAW,IAAI,MAAM,GACtB,MAAM,aAAa,CAAC;AA0BrB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,EACL,UAAU,GAIX,EAAS,EAAE;IACV,OAAO;QACL,GAAG,KAAK;QACR,OAAO,EAAE;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GAAG,IAAI;IACP,OAAO,EAAE;QACP,GAAG,IAAI,CAAC,OAAO;QACf,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,uCAAuC,CAAC;SAChD;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,GAAG,GAAG;IACN,OAAO,EAAE;QACP,GAAG,GAAG,CAAC,OAAO;QACd,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,0CAA0C,CAAC;SACnD;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,GAAG,KAAK;IACR,OAAO,EAAE;QACP,GAAG,KAAK,CAAC,OAAO;KACjB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAU,WAAW,CAAC;IAC/C,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,iBAAiB;IACvB,cAAc,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;IACtE,OAAO,EAAE;QACP,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,sCAAsC,CAAC;SAC/C;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,IAAI,GAAU;IACzB,GAAG,KAAK;IACR,OAAO,EAAE;QACP,GAAG,KAAK,CAAC,OAAO;KACjB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAU;IAChC,GAAG,MAAM;IACT,OAAO,EAAE;QACP,GAAG,MAAM,CAAC,OAAO;KAClB;CACF,CAAC","sourcesContent":["import type { Chain } from \"viem\";\n\nimport { defineChain } from \"viem\";\nimport {\n arbitrum as vab,\n arbitrumGoerli as vabg,\n arbitrumSepolia as vabs,\n base as vbase,\n baseGoerli as vbaseg,\n baseSepolia as vbases,\n fraxtal as vfrax,\n goerli as vgo,\n mainnet as vmain,\n optimism as vop,\n optimismGoerli as vopg,\n optimismSepolia as vops,\n polygon as vpg,\n polygonAmoy as vpga,\n polygonMumbai as vpgm,\n sepolia as vsep,\n zora as vzora,\n zoraSepolia as vzoras,\n} from \"viem/chains\";\n\nexport type AlchemyChainConfig = {\n chain: Chain;\n rpcBaseUrl: string;\n};\n\n/**\n * Defines an Alchemy chain configuration by adding an Alchemy-specific RPC base URL to the chain's RPC URLs.\n *\n * @example\n * ```ts\n * import { defineAlchemyChain } from \"@account-kit/infra\";\n * import { sepolia } from \"viem/chains\";\n *\n * const chain = defineAlchemyChain({\n * chain: sepolia,\n * rpcBaseUrl: \"https://eth-sepolia.g.alchemy.com/v2\"\n * });\n * ```\n *\n * @param {AlchemyChainConfig} params The parameters for defining the Alchemy chain\n * @param {Chain} params.chain The original chain configuration\n * @param {string} params.rpcBaseUrl The Alchemy-specific RPC base URL\n * @returns {Chain} The updated chain configuration with the Alchemy RPC URL added\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\nexport const arbitrum: Chain = {\n ...vab,\n rpcUrls: {\n ...vab.rpcUrls,\n alchemy: {\n http: [\"https://arb-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumGoerli: Chain = {\n ...vabg,\n rpcUrls: {\n ...vabg.rpcUrls,\n alchemy: {\n http: [\"https://arb-goerli.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumSepolia: Chain = {\n ...vabs,\n rpcUrls: {\n ...vabs.rpcUrls,\n alchemy: {\n http: [\"https://arb-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const goerli: Chain = {\n ...vgo,\n rpcUrls: {\n ...vgo.rpcUrls,\n alchemy: {\n http: [\"https://eth-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const mainnet: Chain = {\n ...vmain,\n rpcUrls: {\n ...vmain.rpcUrls,\n alchemy: {\n http: [\"https://eth-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimism: Chain = {\n ...vop,\n rpcUrls: {\n ...vop.rpcUrls,\n alchemy: {\n http: [\"https://opt-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismGoerli: Chain = {\n ...vopg,\n rpcUrls: {\n ...vopg.rpcUrls,\n alchemy: {\n http: [\"https://opt-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismSepolia: Chain = {\n ...vops,\n rpcUrls: {\n ...vops.rpcUrls,\n alchemy: {\n http: [\"https://opt-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const sepolia: Chain = {\n ...vsep,\n rpcUrls: {\n ...vsep.rpcUrls,\n alchemy: {\n http: [\"https://eth-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const base: Chain = {\n ...vbase,\n rpcUrls: {\n ...vbase.rpcUrls,\n alchemy: {\n http: [\"https://base-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseGoerli: Chain = {\n ...vbaseg,\n rpcUrls: {\n ...vbaseg.rpcUrls,\n alchemy: {\n http: [\"https://base-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseSepolia: Chain = {\n ...vbases,\n rpcUrls: {\n ...vbases.rpcUrls,\n alchemy: {\n http: [\"https://base-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonMumbai: Chain = {\n ...vpgm,\n rpcUrls: {\n ...vpgm.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mumbai.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonAmoy: Chain = {\n ...vpga,\n rpcUrls: {\n ...vpga.rpcUrls,\n alchemy: {\n http: [\"https://polygon-amoy.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygon: Chain = {\n ...vpg,\n rpcUrls: {\n ...vpg.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const fraxtal: Chain = {\n ...vfrax,\n rpcUrls: {\n ...vfrax.rpcUrls,\n },\n};\n\nexport const fraxtalSepolia: Chain = defineChain({\n id: 2523,\n name: \"Fraxtal Sepolia\",\n nativeCurrency: { name: \"Frax Ether\", symbol: \"frxETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://rpc.testnet-sepolia.frax.com\"],\n },\n },\n});\n\nexport const zora: Chain = {\n ...vzora,\n rpcUrls: {\n ...vzora.rpcUrls,\n },\n};\n\nexport const zoraSepolia: Chain = {\n ...vzoras,\n rpcUrls: {\n ...vzoras.rpcUrls,\n },\n};\n"]}
1
+ {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EACL,QAAQ,IAAI,GAAG,EACf,cAAc,IAAI,IAAI,EACtB,eAAe,IAAI,IAAI,EACvB,IAAI,IAAI,KAAK,EACb,UAAU,IAAI,MAAM,EACpB,WAAW,IAAI,MAAM,EACrB,OAAO,IAAI,KAAK,EAChB,MAAM,IAAI,GAAG,EACb,OAAO,IAAI,KAAK,EAChB,QAAQ,IAAI,GAAG,EACf,cAAc,IAAI,IAAI,EACtB,eAAe,IAAI,IAAI,EACvB,OAAO,IAAI,GAAG,EACd,WAAW,IAAI,IAAI,EACnB,aAAa,IAAI,IAAI,EACrB,OAAO,IAAI,IAAI,EACf,IAAI,IAAI,KAAK,EACb,WAAW,IAAI,MAAM,GACtB,MAAM,aAAa,CAAC;AA0BrB,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;AAEF,MAAM,CAAC,MAAM,QAA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tD;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAU,WAAW,CAAC;IAC3C,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,aAAa;IACtB,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC9D,OAAO,EAAE;QACP,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,6CAA6C,CAAC;SACtD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,6CAA6C,CAAC;SACtD;QACD,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,6CAA6C,CAAC;SACtD;KACF;CACF,CAAC,CAAC","sourcesContent":["import type { Chain } from \"viem\";\n\nimport { defineChain } from \"viem\";\nimport {\n arbitrum as vab,\n arbitrumGoerli as vabg,\n arbitrumSepolia as vabs,\n base as vbase,\n baseGoerli as vbaseg,\n baseSepolia as vbases,\n fraxtal as vfrax,\n goerli as vgo,\n mainnet as vmain,\n optimism as vop,\n optimismGoerli as vopg,\n optimismSepolia as vops,\n polygon as vpg,\n polygonAmoy as vpga,\n polygonMumbai as vpgm,\n sepolia as vsep,\n zora as vzora,\n zoraSepolia as vzoras,\n} from \"viem/chains\";\n\nexport type AlchemyChainConfig = {\n chain: Chain;\n rpcBaseUrl: string;\n};\n\n/**\n * Defines an Alchemy chain configuration by adding an Alchemy-specific RPC base URL to the chain's RPC URLs.\n *\n * @example\n * ```ts\n * import { defineAlchemyChain } from \"@account-kit/infra\";\n * import { sepolia } from \"viem/chains\";\n *\n * const chain = defineAlchemyChain({\n * chain: sepolia,\n * rpcBaseUrl: \"https://eth-sepolia.g.alchemy.com/v2\"\n * });\n * ```\n *\n * @param {AlchemyChainConfig} params The parameters for defining the Alchemy chain\n * @param {Chain} params.chain The original chain configuration\n * @param {string} params.rpcBaseUrl The Alchemy-specific RPC base URL\n * @returns {Chain} The updated chain configuration with the Alchemy RPC URL added\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\nexport const arbitrum: Chain = {\n ...vab,\n rpcUrls: {\n ...vab.rpcUrls,\n alchemy: {\n http: [\"https://arb-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumGoerli: Chain = {\n ...vabg,\n rpcUrls: {\n ...vabg.rpcUrls,\n alchemy: {\n http: [\"https://arb-goerli.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumSepolia: Chain = {\n ...vabs,\n rpcUrls: {\n ...vabs.rpcUrls,\n alchemy: {\n http: [\"https://arb-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const goerli: Chain = {\n ...vgo,\n rpcUrls: {\n ...vgo.rpcUrls,\n alchemy: {\n http: [\"https://eth-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const mainnet: Chain = {\n ...vmain,\n rpcUrls: {\n ...vmain.rpcUrls,\n alchemy: {\n http: [\"https://eth-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimism: Chain = {\n ...vop,\n rpcUrls: {\n ...vop.rpcUrls,\n alchemy: {\n http: [\"https://opt-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismGoerli: Chain = {\n ...vopg,\n rpcUrls: {\n ...vopg.rpcUrls,\n alchemy: {\n http: [\"https://opt-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismSepolia: Chain = {\n ...vops,\n rpcUrls: {\n ...vops.rpcUrls,\n alchemy: {\n http: [\"https://opt-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const sepolia: Chain = {\n ...vsep,\n rpcUrls: {\n ...vsep.rpcUrls,\n alchemy: {\n http: [\"https://eth-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const base: Chain = {\n ...vbase,\n rpcUrls: {\n ...vbase.rpcUrls,\n alchemy: {\n http: [\"https://base-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseGoerli: Chain = {\n ...vbaseg,\n rpcUrls: {\n ...vbaseg.rpcUrls,\n alchemy: {\n http: [\"https://base-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseSepolia: Chain = {\n ...vbases,\n rpcUrls: {\n ...vbases.rpcUrls,\n alchemy: {\n http: [\"https://base-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonMumbai: Chain = {\n ...vpgm,\n rpcUrls: {\n ...vpgm.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mumbai.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonAmoy: Chain = {\n ...vpga,\n rpcUrls: {\n ...vpga.rpcUrls,\n alchemy: {\n http: [\"https://polygon-amoy.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygon: Chain = {\n ...vpg,\n rpcUrls: {\n ...vpg.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const fraxtal: Chain = {\n ...vfrax,\n rpcUrls: {\n ...vfrax.rpcUrls,\n },\n};\n\nexport const fraxtalSepolia: Chain = defineChain({\n id: 2523,\n name: \"Fraxtal Sepolia\",\n nativeCurrency: { name: \"Frax Ether\", symbol: \"frxETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://rpc.testnet-sepolia.frax.com\"],\n },\n },\n});\n\nexport const zora: Chain = {\n ...vzora,\n rpcUrls: {\n ...vzora.rpcUrls,\n },\n};\n\nexport const zoraSepolia: Chain = {\n ...vzoras,\n rpcUrls: {\n ...vzoras.rpcUrls,\n },\n};\n\nexport const worldChainSepolia: Chain = defineChain({\n id: 4801,\n name: \"World Chain Sepolia\",\n network: \"World Chain Sepolia\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const worldChain: Chain = defineChain({\n id: 480,\n name: \"World Chain\",\n network: \"World Chain\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n },\n});\n"]}
@@ -1 +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;AA4CD,MAAM,UAAU,4CAA4C,CAC1D,IAAwD;IAExD,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,GACP,GAAG,IAAI,CAAC;IACT,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,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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 CreateAlchemySmartAccountClientFromRpcClientParams<\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: CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>\n): AlchemySmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\n/**\n * Creates an AlchemySmartAccountClient using the provided RPC client configuration, including options, account, simulation settings, gas management, fee estimation, middleware and user operation signing.\n *\n * @example\n * ```ts\n * import { createAlchemySmartAccountClientFromRpcClient, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n *\n * const client = createAlchemyPublicRpcClient(...);\n * const scaClient = createAlchemySmartAccountClientFromRpcClient({\n * client,\n * ...\n * });\n * ```\n *\n * @param {CreateAlchemySmartAccountClientFromRpcClientParams} args The configuration object containing all required parameters\n * @returns {AlchemySmartAccountClient} An instance of AlchemySmartAccountClient\n */\nexport function createAlchemySmartAccountClientFromRpcClient(\n args: CreateAlchemySmartAccountClientFromRpcClientParams\n): AlchemySmartAccountClient {\n const {\n opts,\n account,\n useSimulation,\n gasManagerConfig,\n feeEstimator,\n gasEstimator,\n customMiddleware,\n signUserOperation,\n client,\n } = args;\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"]}
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;AA4CD,MAAM,UAAU,4CAA4C,CAC1D,IAAwD;IAExD,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,GACP,GAAG,IAAI,CAAC;IACT,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 CreateAlchemySmartAccountClientFromRpcClientParams<\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 {CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>} args configuration for the client\n * @returns {AlchemySmartAccountClient} 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: CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>\n): AlchemySmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\n/**\n * Creates an AlchemySmartAccountClient using the provided RPC client configuration, including options, account, simulation settings, gas management, fee estimation, middleware and user operation signing.\n *\n * @example\n * ```ts\n * import { createAlchemySmartAccountClientFromRpcClient, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n *\n * const client = createAlchemyPublicRpcClient(...);\n * const scaClient = createAlchemySmartAccountClientFromRpcClient({\n * client,\n * ...\n * });\n * ```\n *\n * @param {CreateAlchemySmartAccountClientFromRpcClientParams} args The configuration object containing all required parameters\n * @returns {AlchemySmartAccountClient} An instance of AlchemySmartAccountClient\n */\nexport function createAlchemySmartAccountClientFromRpcClient(\n args: CreateAlchemySmartAccountClientFromRpcClientParams\n): AlchemySmartAccountClient {\n const {\n opts,\n account,\n useSimulation,\n gasManagerConfig,\n feeEstimator,\n gasEstimator,\n customMiddleware,\n signUserOperation,\n client,\n } = args;\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"]}
@@ -2,7 +2,7 @@ export type * from "./actions/simulateUserOperationChanges.js";
2
2
  export { simulateUserOperationChanges } from "./actions/simulateUserOperationChanges.js";
3
3
  export type * from "./actions/types.js";
4
4
  export type * from "./chains.js";
5
- export { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, zora, zoraSepolia, } from "./chains.js";
5
+ export { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, zora, zoraSepolia, worldChain, worldChainSepolia, } from "./chains.js";
6
6
  export type * from "./client/decorators/alchemyEnhancedApis.js";
7
7
  export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
8
8
  export type * from "./client/decorators/smartAccount.js";
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { simulateUserOperationChanges } from "./actions/simulateUserOperationChanges.js";
2
- export { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, zora, zoraSepolia, } from "./chains.js";
2
+ export { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, zora, zoraSepolia, worldChain, worldChainSepolia, } from "./chains.js";
3
3
  export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
4
4
  export { alchemyActions } from "./client/decorators/smartAccount.js";
5
5
  export { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from "./client/internal/smartAccountClientFromRpc.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAGzF,OAAO,EACL,QAAQ,EACR,cAAc,EACd,eAAe,EACf,IAAI,EACJ,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,EACR,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,IAAI,EACJ,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,4CAA4C,IAAI,2CAA2C,EAAE,MAAM,gDAAgD,CAAC;AAC7J,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport type * from \"./chains.js\";\nexport {\n arbitrum,\n arbitrumGoerli,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n defineAlchemyChain,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n zora,\n zoraSepolia,\n} from \"./chains.js\";\nexport type * from \"./client/decorators/alchemyEnhancedApis.js\";\nexport { alchemyEnhancedApiActions } from \"./client/decorators/alchemyEnhancedApis.js\";\nexport type * from \"./client/decorators/smartAccount.js\";\nexport { alchemyActions } from \"./client/decorators/smartAccount.js\";\nexport { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from \"./client/internal/smartAccountClientFromRpc.js\";\nexport { isAlchemySmartAccountClient } from \"./client/isAlchemySmartAccountClient.js\";\nexport type * from \"./client/rpcClient.js\";\nexport { createAlchemyPublicRpcClient } from \"./client/rpcClient.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport { createAlchemySmartAccountClient } from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport { getDefaultUserOperationFeeOptions } from \"./defaults.js\";\nexport { getAlchemyPaymasterAddress } from \"./gas-manager.js\";\nexport { alchemyFeeEstimator } from \"./middleware/feeEstimator.js\";\nexport type * from \"./middleware/gasManager.js\";\nexport { alchemyGasManagerMiddleware } from \"./middleware/gasManager.js\";\nexport { alchemyUserOperationSimulator } from \"./middleware/userOperationSimulator.js\";\nexport type * from \"./schema.js\";\nexport { AlchemyProviderConfigSchema } from \"./schema.js\";\nexport type { AlchemyProviderConfig } from \"./type.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAGzF,OAAO,EACL,QAAQ,EACR,cAAc,EACd,eAAe,EACf,IAAI,EACJ,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,EACR,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,IAAI,EACJ,WAAW,EACX,UAAU,EACV,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,4CAA4C,IAAI,2CAA2C,EAAE,MAAM,gDAAgD,CAAC;AAC7J,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport type * from \"./chains.js\";\nexport {\n arbitrum,\n arbitrumGoerli,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n defineAlchemyChain,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n zora,\n zoraSepolia,\n worldChain,\n worldChainSepolia,\n} from \"./chains.js\";\nexport type * from \"./client/decorators/alchemyEnhancedApis.js\";\nexport { alchemyEnhancedApiActions } from \"./client/decorators/alchemyEnhancedApis.js\";\nexport type * from \"./client/decorators/smartAccount.js\";\nexport { alchemyActions } from \"./client/decorators/smartAccount.js\";\nexport { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from \"./client/internal/smartAccountClientFromRpc.js\";\nexport { isAlchemySmartAccountClient } from \"./client/isAlchemySmartAccountClient.js\";\nexport type * from \"./client/rpcClient.js\";\nexport { createAlchemyPublicRpcClient } from \"./client/rpcClient.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport { createAlchemySmartAccountClient } from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport { getDefaultUserOperationFeeOptions } from \"./defaults.js\";\nexport { getAlchemyPaymasterAddress } from \"./gas-manager.js\";\nexport { alchemyFeeEstimator } from \"./middleware/feeEstimator.js\";\nexport type * from \"./middleware/gasManager.js\";\nexport { alchemyGasManagerMiddleware } from \"./middleware/gasManager.js\";\nexport { alchemyUserOperationSimulator } from \"./middleware/userOperationSimulator.js\";\nexport type * from \"./schema.js\";\nexport { AlchemyProviderConfigSchema } from \"./schema.js\";\nexport type { AlchemyProviderConfig } from \"./type.js\";\n"]}
@@ -2,11 +2,16 @@ import { bypassPaymasterAndDataEmptyHex, deepHexlify, defaultGasEstimator, filte
2
2
  import { concat, fromHex, isHex } from "viem";
3
3
  import { getAlchemyPaymasterAddress } from "../gas-manager.js";
4
4
  import { alchemyFeeEstimator } from "./feeEstimator.js";
5
- const dummyPaymasterAndData = (client, config) => () => {
5
+ const dummyPaymasterAndData = (client, config) => async (uo) => {
6
6
  const paymaster = config.paymasterAddress ?? getAlchemyPaymasterAddress(client.chain);
7
7
  const paymasterData = config.dummyData ??
8
8
  "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
9
- return concat([paymaster, paymasterData]);
9
+ return {
10
+ ...uo,
11
+ paymaster,
12
+ paymasterData,
13
+ paymasterAndData: concat([paymaster, paymasterData]),
14
+ };
10
15
  };
11
16
  export function alchemyGasManagerMiddleware(client, config) {
12
17
  const gasEstimationOptions = config.gasEstimationOptions;
@@ -53,9 +58,9 @@ export function alchemyGasManagerMiddleware(client, config) {
53
58
  maxPriorityFeePerGas,
54
59
  };
55
60
  },
56
- paymasterAndData: disableGasEstimation
61
+ ...(disableGasEstimation
57
62
  ? requestPaymasterAndData(client, config)
58
- : requestGasAndPaymasterData(client, config),
63
+ : requestGasAndPaymasterData(client, config)),
59
64
  };
60
65
  }
61
66
  const overrideField = (field, overrides, feeOptions, userOperation) => {
@@ -1 +1 @@
1
- {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,8BAA8B,EAC9B,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAY,MAAM,MAAM,CAAC;AAExD,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAoIxD,MAAM,qBAAqB,GACzB,CACE,MAAS,EACT,MAA+B,EAC/B,EAAE,CACJ,GAAG,EAAE;IACH,MAAM,SAAS,GACb,MAAM,CAAC,gBAAgB,IAAI,0BAA0B,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,MAAM,aAAa,GACjB,MAAM,CAAC,SAAS;QAChB,sMAAsM,CAAC;IAEzM,OAAO,MAAM,CAAC,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC;AAUJ,MAAM,UAAU,2BAA2B,CACzC,MAAS,EACT,MAA+B;IAK/B,MAAM,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC;IACzD,MAAM,oBAAoB,GACxB,oBAAoB,EAAE,oBAAoB,IAAI,KAAK,CAAC;IACtD,MAAM,qBAAqB,GACzB,oBAAoB,EAAE,qBAAqB,IAAI,mB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EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;wBAC3C,aAAa;wBACb,cAAc,EAAE,aAAa,CAAC,SAAS;wBACvC,SAAS;qBACV;iBACF;aACF,CAAC,CAAC;YAEH,OAAO;gBACL,GAAG,MAAM;gBACT,GAAG,MAAM;aACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAWD,MAAM,uBAAuB,GAGqB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACrE,qBAAqB,EAAE,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC;IAC5D,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YAClC,MAAM,EAAE,iCAAiC;YACzC,MAAM,EAAE;gBACN;oBACE,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;oBAC3C,aAAa,EAAE,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;iBAC5D;aACF;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,MAAM;YACT,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type {\n Address,\n ClientMiddlewareConfig,\n ClientMiddlewareFn,\n EntryPointVersion,\n Multiplier,\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport {\n bypassPaymasterAndDataEmptyHex,\n deepHexlify,\n defaultGasEstimator,\n filterUndefined,\n isBigNumberish,\n isMultiplier,\n resolveProperties,\n} from \"@aa-sdk/core\";\nimport { concat, fromHex, isHex, type Hex } from \"viem\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\nimport { getAlchemyPaymasterAddress } from \"../gas-manager.js\";\nimport { alchemyFeeEstimator } from \"./feeEstimator.js\";\n\n/**\n * overrides value for [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Partial<\n {\n maxFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxFeePerGas\"]\n | Multiplier;\n maxPriorityFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxPriorityFeePerGas\"]\n | Multiplier;\n callGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"callGasLimit\"]\n | Multiplier;\n verificationGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"verificationGasLimit\"]\n | Multiplier;\n preVerificationGas:\n | UserOperationRequest<TEntryPointVersion>[\"preVerificationGas\"]\n | Multiplier;\n } & TEntryPointVersion extends \"0.7.0\"\n ? {\n paymasterVerificationGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterVerificationGasLimit\"]\n | Multiplier;\n paymasterPostOpGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterPostOpGasLimit\"]\n | Multiplier;\n }\n : {}\n>;\n\n/**\n * [`alchemy-requestpaymasteranddata`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? {\n paymasterAndData: UserOperationRequest<\"0.6.0\">[\"paymasterAndData\"];\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? Pick<UserOperationRequest<\"0.7.0\">, \"paymaster\" | \"paymasterData\">\n : {};\n\n/**\n * [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Pick<\n UserOperationRequest,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n | \"maxFeePerGas\"\n | \"maxPriorityFeePerGas\"\n> &\n RequestPaymasterAndDataResponse<TEntryPointVersion>;\n\n/**\n * Alchemy gas manager configuration with gas policy id and optional gas estimation options\n *\n * To create a Gas Manager Policy, go to the [gas manager](https://dashboard.alchemy.com/gas-manager?a=embedded-accounts-get-started)\n * page of the Alchemy dashboard and click the “Create new policy” button.\n */\nexport interface AlchemyGasManagerConfig {\n /**\n * the policy id of the gas manager you want to use.\n *\n */\n policyId: string;\n /**\n * optional option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\n gasEstimationOptions?: AlchemyGasEstimationOptions;\n /**\n * paymaster address to use for the gas estimation.\n * If not provided, the default paymaster address for the chain will be used.\n *\n */\n paymasterAddress?: Address;\n /**\n * dummy paymaster data to use for the gas estimation.\n *\n */\n dummyData?: Hex;\n}\n\n/**\n * Alchemy gas manager configuration option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\nexport interface AlchemyGasEstimationOptions {\n /**\n * disable gas estimation and fallback to the default gas estimation.\n *\n */\n disableGasEstimation: boolean;\n /**\n * optional fallback gas estimator to use when gas estimation is disabled.\n *\n */\n fallbackGasEstimator?: ClientMiddlewareFn;\n /**\n * optional fallback fee estimator to use when gas estimation is disabled.\n *\n */\n fallbackFeeDataGetter?: ClientMiddlewareFn;\n}\n\n/**\n * Dummy paymaster and data middleware for the alchemy gas manager\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the dummyPaymasterAndData middleware for Alchemy gas manager\n */\nconst dummyPaymasterAndData =\n <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n ) =>\n () => {\n const paymaster =\n config.paymasterAddress ?? getAlchemyPaymasterAddress(client.chain);\n const paymasterData =\n config.dummyData ??\n \"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return concat([paymaster, paymasterData]); // or you can also return { paymaster, paymasterData }\n };\n\n/**\n * Alchemy gas manager middleware used as the paymaster middleware overrides param to the client middleware config\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager\n */\nexport function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): Pick<\n ClientMiddlewareConfig,\n \"paymasterAndData\" | \"feeEstimator\" | \"gasEstimator\"\n> {\n const gasEstimationOptions = config.gasEstimationOptions;\n const disableGasEstimation =\n gasEstimationOptions?.disableGasEstimation ?? false;\n const fallbackFeeDataGetter =\n gasEstimationOptions?.fallbackFeeDataGetter ?? alchemyFeeEstimator(client);\n const fallbackGasEstimator =\n gasEstimationOptions?.fallbackGasEstimator ??\n defaultGasEstimator<C>(client);\n\n return {\n gasEstimator: disableGasEstimation\n ? fallbackGasEstimator\n : async (struct, { overrides, account, feeOptions }) => {\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n return {\n ...struct,\n ...(await fallbackGasEstimator(struct, {\n overrides,\n account,\n feeOptions,\n client,\n })),\n };\n }\n\n // essentially noop, because the gas estimation will happen in the backend\n return struct;\n },\n feeEstimator: disableGasEstimation\n ? fallbackFeeDataGetter\n : async (struct, { overrides, account, feeOptions }) => {\n let maxFeePerGas = await struct.maxFeePerGas;\n let maxPriorityFeePerGas = await struct.maxPriorityFeePerGas;\n\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n const result = await fallbackFeeDataGetter(struct, {\n overrides,\n feeOptions,\n account,\n client,\n });\n maxFeePerGas = (await result.maxFeePerGas) ?? maxFeePerGas;\n maxPriorityFeePerGas =\n (await result.maxPriorityFeePerGas) ?? maxPriorityFeePerGas;\n }\n\n return {\n ...struct,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n },\n paymasterAndData: disableGasEstimation\n ? requestPaymasterAndData(client, config)\n : requestGasAndPaymasterData(client, config),\n };\n}\n\n/**\n * Utility function to override a field in the user operation request with the overrides or fee options\n *\n * @template {EntryPointVersion} TEntryPointVersion\n * @param field the field to override\n * @param overrides the overrides object\n * @param feeOptions the fee options object from the client\n * @param userOperation the user operation request\n * @returns the overridden field value\n */\nconst overrideField = <\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n field: keyof UserOperationFeeOptions<TEntryPointVersion>,\n overrides: UserOperationOverrides<TEntryPointVersion> | undefined,\n feeOptions: UserOperationFeeOptions<TEntryPointVersion> | undefined,\n userOperation: UserOperationRequest<TEntryPointVersion>\n): Hex | Multiplier | undefined => {\n let _field = field as keyof UserOperationOverrides<TEntryPointVersion>;\n\n if (overrides?.[_field] != null) {\n // one-off absolute override\n if (isBigNumberish(overrides[_field])) {\n return deepHexlify(overrides[_field]);\n }\n // one-off multiplier overrides\n else {\n return {\n multiplier: Number((overrides[_field] as Multiplier).multiplier),\n };\n }\n }\n\n // provider level fee options with multiplier\n if (isMultiplier(feeOptions?.[field])) {\n return {\n multiplier: Number((feeOptions![field] as Multiplier).multiplier),\n };\n }\n\n const userOpField =\n userOperation[field as keyof UserOperationRequest<TEntryPointVersion>];\n if (isHex(userOpField) && fromHex(userOpField as Hex, \"bigint\") > 0n) {\n return userOpField;\n }\n return undefined;\n};\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestGasAndPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager\n */\nfunction requestGasAndPaymasterData<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): ClientMiddlewareConfig[\"paymasterAndData\"] {\n return {\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n\n paymasterAndData: async (\n struct,\n { overrides: overrides_, feeOptions, account }\n ) => {\n const userOperation: UserOperationRequest = deepHexlify(\n await resolveProperties(struct)\n );\n\n const overrides: RequestGasAndPaymasterAndDataOverrides = filterUndefined(\n {\n maxFeePerGas: overrideField(\n \"maxFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n maxPriorityFeePerGas: overrideField(\n \"maxPriorityFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n callGasLimit: overrideField(\n \"callGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n verificationGasLimit: overrideField(\n \"verificationGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n preVerificationGas: overrideField(\n \"preVerificationGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n }\n );\n\n if (account.getEntryPoint().version === \"0.7.0\") {\n const paymasterVerificationGasLimit = overrideField<\"0.7.0\">(\n \"paymasterVerificationGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterVerificationGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterVerificationGasLimit = paymasterVerificationGasLimit;\n }\n\n const paymasterPostOpGasLimit = overrideField<\"0.7.0\">(\n \"paymasterPostOpGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterPostOpGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterPostOpGasLimit = paymasterPostOpGasLimit;\n }\n }\n\n const result = await client.request({\n method: \"alchemy_requestGasAndPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation,\n dummySignature: userOperation.signature,\n overrides,\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n };\n}\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * with gas estimation disabled.\n *\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager with gas estimation disabled\n */\nconst requestPaymasterAndData: <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n) => ClientMiddlewareConfig[\"paymasterAndData\"] = (client, config) => ({\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n paymasterAndData: async (struct, { account }) => {\n const result = await client.request({\n method: \"alchemy_requestPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation: deepHexlify(await resolveProperties(struct)),\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n});\n"]}
1
+ {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,8BAA8B,EAC9B,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAY,MAAM,MAAM,CAAC;AAExD,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OA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QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;oBAC3C,aAAa,EAAE,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;iBAC5D;aACF;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,MAAM;YACT,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type {\n Address,\n ClientMiddlewareConfig,\n ClientMiddlewareFn,\n EntryPointVersion,\n Multiplier,\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport {\n bypassPaymasterAndDataEmptyHex,\n deepHexlify,\n defaultGasEstimator,\n filterUndefined,\n isBigNumberish,\n isMultiplier,\n resolveProperties,\n} from \"@aa-sdk/core\";\nimport { concat, fromHex, isHex, type Hex } from \"viem\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\nimport { getAlchemyPaymasterAddress } from \"../gas-manager.js\";\nimport { alchemyFeeEstimator } from \"./feeEstimator.js\";\n\n/**\n * overrides value for [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Partial<\n {\n maxFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxFeePerGas\"]\n | Multiplier;\n maxPriorityFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxPriorityFeePerGas\"]\n | Multiplier;\n callGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"callGasLimit\"]\n | Multiplier;\n verificationGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"verificationGasLimit\"]\n | Multiplier;\n preVerificationGas:\n | UserOperationRequest<TEntryPointVersion>[\"preVerificationGas\"]\n | Multiplier;\n } & TEntryPointVersion extends \"0.7.0\"\n ? {\n paymasterVerificationGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterVerificationGasLimit\"]\n | Multiplier;\n paymasterPostOpGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterPostOpGasLimit\"]\n | Multiplier;\n }\n : {}\n>;\n\n/**\n * [`alchemy-requestpaymasteranddata`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? {\n paymasterAndData: UserOperationRequest<\"0.6.0\">[\"paymasterAndData\"];\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? Pick<UserOperationRequest<\"0.7.0\">, \"paymaster\" | \"paymasterData\">\n : {};\n\n/**\n * [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Pick<\n UserOperationRequest,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n | \"maxFeePerGas\"\n | \"maxPriorityFeePerGas\"\n> &\n RequestPaymasterAndDataResponse<TEntryPointVersion>;\n\n/**\n * Alchemy gas manager configuration with gas policy id and optional gas estimation options\n *\n * To create a Gas Manager Policy, go to the [gas manager](https://dashboard.alchemy.com/gas-manager?a=embedded-accounts-get-started)\n * page of the Alchemy dashboard and click the “Create new policy” button.\n */\nexport interface AlchemyGasManagerConfig {\n /**\n * the policy id of the gas manager you want to use.\n *\n */\n policyId: string;\n /**\n * optional option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\n gasEstimationOptions?: AlchemyGasEstimationOptions;\n /**\n * paymaster address to use for the gas estimation.\n * If not provided, the default paymaster address for the chain will be used.\n *\n */\n paymasterAddress?: Address;\n /**\n * dummy paymaster data to use for the gas estimation.\n *\n */\n dummyData?: Hex;\n}\n\n/**\n * Alchemy gas manager configuration option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\nexport interface AlchemyGasEstimationOptions {\n /**\n * disable gas estimation and fallback to the default gas estimation.\n *\n */\n disableGasEstimation: boolean;\n /**\n * optional fallback gas estimator to use when gas estimation is disabled.\n *\n */\n fallbackGasEstimator?: ClientMiddlewareFn;\n /**\n * optional fallback fee estimator to use when gas estimation is disabled.\n *\n */\n fallbackFeeDataGetter?: ClientMiddlewareFn;\n}\n\n/**\n * Dummy paymaster and data middleware for the alchemy gas manager\n *\n * NOTE: right now, this only really works for 0.6.0 unless you pass in overrides in the config for 0.7.0\n *\n * @template {ClientWithAlchemyMethods} C\n * @param {ClientWithAlchemyMethods} client client with alchemy methods\n * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration\n * @returns {() => Hex} the dummyPaymasterAndData middleware for Alchemy gas manager\n */\nconst dummyPaymasterAndData =\n <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n ): ClientMiddlewareFn =>\n async (uo) => {\n const paymaster =\n config.paymasterAddress ?? getAlchemyPaymasterAddress(client.chain);\n const paymasterData =\n config.dummyData ??\n \"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return {\n ...uo,\n paymaster,\n paymasterData,\n paymasterAndData: concat([paymaster, paymasterData]),\n };\n };\n\n/**\n * Alchemy gas manager middleware used as the paymaster middleware overrides param to the client middleware config\n *\n * @template {ClientWithAlchemyMethods} C\n * @param {ClientWithAlchemyMethods} client client with alchemy methods\n * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration\n * @returns {Pick<ClientMiddlewareConfig,\"paymasterAndData\" | \"feeEstimator\" | \"gasEstimator\">} the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager\n */\nexport function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): Pick<\n ClientMiddlewareConfig,\n \"paymasterAndData\" | \"feeEstimator\" | \"gasEstimator\"\n> {\n const gasEstimationOptions = config.gasEstimationOptions;\n const disableGasEstimation =\n gasEstimationOptions?.disableGasEstimation ?? false;\n const fallbackFeeDataGetter =\n gasEstimationOptions?.fallbackFeeDataGetter ?? alchemyFeeEstimator(client);\n const fallbackGasEstimator =\n gasEstimationOptions?.fallbackGasEstimator ??\n defaultGasEstimator<C>(client);\n\n return {\n gasEstimator: disableGasEstimation\n ? fallbackGasEstimator\n : async (struct, { overrides, account, feeOptions }) => {\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n return {\n ...struct,\n ...(await fallbackGasEstimator(struct, {\n overrides,\n account,\n feeOptions,\n client,\n })),\n };\n }\n\n // essentially noop, because the gas estimation will happen in the backend\n return struct;\n },\n feeEstimator: disableGasEstimation\n ? fallbackFeeDataGetter\n : async (struct, { overrides, account, feeOptions }) => {\n let maxFeePerGas = await struct.maxFeePerGas;\n let maxPriorityFeePerGas = await struct.maxPriorityFeePerGas;\n\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n const result = await fallbackFeeDataGetter(struct, {\n overrides,\n feeOptions,\n account,\n client,\n });\n maxFeePerGas = (await result.maxFeePerGas) ?? maxFeePerGas;\n maxPriorityFeePerGas =\n (await result.maxPriorityFeePerGas) ?? maxPriorityFeePerGas;\n }\n\n return {\n ...struct,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n },\n ...(disableGasEstimation\n ? requestPaymasterAndData(client, config)\n : requestGasAndPaymasterData(client, config)),\n };\n}\n\n/**\n * Utility function to override a field in the user operation request with the overrides or fee options\n *\n * @template {EntryPointVersion} TEntryPointVersion\n * @param {keyof UserOperationFeeOptions<TEntryPointVersion>} field the field to override\n * @param {UserOperationOverrides<TEntryPointVersion> | undefined} overrides the overrides object\n * @param {UserOperationFeeOptions<TEntryPointVersion> | undefined} feeOptions the fee options object from the client\n * @param {UserOperationRequest<TEntryPointVersion>} userOperation the user operation request\n * @returns {Hex | Multiplier | undefine} the overridden field value\n */\nconst overrideField = <\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n field: keyof UserOperationFeeOptions<TEntryPointVersion>,\n overrides: UserOperationOverrides<TEntryPointVersion> | undefined,\n feeOptions: UserOperationFeeOptions<TEntryPointVersion> | undefined,\n userOperation: UserOperationRequest<TEntryPointVersion>\n): Hex | Multiplier | undefined => {\n let _field = field as keyof UserOperationOverrides<TEntryPointVersion>;\n\n if (overrides?.[_field] != null) {\n // one-off absolute override\n if (isBigNumberish(overrides[_field])) {\n return deepHexlify(overrides[_field]);\n }\n // one-off multiplier overrides\n else {\n return {\n multiplier: Number((overrides[_field] as Multiplier).multiplier),\n };\n }\n }\n\n // provider level fee options with multiplier\n if (isMultiplier(feeOptions?.[field])) {\n return {\n multiplier: Number((feeOptions![field] as Multiplier).multiplier),\n };\n }\n\n const userOpField =\n userOperation[field as keyof UserOperationRequest<TEntryPointVersion>];\n if (isHex(userOpField) && fromHex(userOpField as Hex, \"bigint\") > 0n) {\n return userOpField;\n }\n return undefined;\n};\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestGasAndPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {ClientWithAlchemyMethods} C\n * @param {ClientWithAlchemyMethods} client client with alchemy methods\n * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration\n * @returns {ClientMiddlewareConfig[\"paymasterAndData\"]} the paymasterAndData middleware for Alchemy gas manager\n */\nfunction requestGasAndPaymasterData<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n return {\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n paymasterAndData: async (\n struct,\n { overrides: overrides_, feeOptions, account }\n ) => {\n const userOperation: UserOperationRequest = deepHexlify(\n await resolveProperties(struct)\n );\n\n const overrides: RequestGasAndPaymasterAndDataOverrides = filterUndefined(\n {\n maxFeePerGas: overrideField(\n \"maxFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n maxPriorityFeePerGas: overrideField(\n \"maxPriorityFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n callGasLimit: overrideField(\n \"callGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n verificationGasLimit: overrideField(\n \"verificationGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n preVerificationGas: overrideField(\n \"preVerificationGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n }\n );\n\n if (account.getEntryPoint().version === \"0.7.0\") {\n const paymasterVerificationGasLimit = overrideField<\"0.7.0\">(\n \"paymasterVerificationGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterVerificationGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterVerificationGasLimit = paymasterVerificationGasLimit;\n }\n\n const paymasterPostOpGasLimit = overrideField<\"0.7.0\">(\n \"paymasterPostOpGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterPostOpGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterPostOpGasLimit = paymasterPostOpGasLimit;\n }\n }\n\n const result = await client.request({\n method: \"alchemy_requestGasAndPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation,\n dummySignature: userOperation.signature,\n overrides,\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n };\n}\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * with gas estimation disabled.\n *\n * @param {ClientWithAlchemyMethods} client client with alchemy methods\n * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration\n * @returns {ClientMiddlewareConfig[\"paymasterAndData\"]} the paymasterAndData middleware for Alchemy gas manager with gas estimation disabled\n */\nconst requestPaymasterAndData: <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n) => Pick<\n ClientMiddlewareConfig,\n \"dummyPaymasterAndData\" | \"paymasterAndData\"\n> = (client, config) => ({\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n paymasterAndData: async (struct, { account }) => {\n const result = await client.request({\n method: \"alchemy_requestPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation: deepHexlify(await resolveProperties(struct)),\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n});\n"]}
@@ -1,3 +1,3 @@
1
- import { type ClientMiddlewareFn } from "@aa-sdk/core";
1
+ import { type ClientMiddlewareFn, type UserOperationContext } from "@aa-sdk/core";
2
2
  import type { ClientWithAlchemyMethods } from "../client/types";
3
- export declare function alchemyUserOperationSimulator<C extends ClientWithAlchemyMethods>(client: C): ClientMiddlewareFn;
3
+ export declare function alchemyUserOperationSimulator<C extends ClientWithAlchemyMethods, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: C): ClientMiddlewareFn<TContext>;
@@ -1 +1 @@
1
- {"version":3,"file":"userOperationSimulator.js","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,GAElB,MAAM,cAAc,CAAC;AAsBtB,MAAM,UAAU,6BAA6B,CAE3C,MAAS;IACT,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACvC,MAAM,EAAE,2CAA2C;YACnD,MAAM,EAAE;gBACN,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;gBAC5C,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;aAChC;SACF,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n deepHexlify,\n resolveProperties,\n type ClientMiddlewareFn,\n} from \"@aa-sdk/core\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\n\n/**\n * A middleware function to be used during simulation of user operations which leverages Alchemy's RPC uo simulation method.\n *\n * @example\n * ```ts\n * import { alchemyUserOperationSimulator, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createAlchemyPublicRpcClient(...);\n * const client = createSmartAccountClient({\n * userOperationSimulator: alchemyUserOperationSimulator(bundlerClient),\n * ...otherParams\n * });\n * ```\n *\n * @template C The client object with Alchemy methods\n * @param {C} client The client object with Alchemy methods\n * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations\n */\nexport function alchemyUserOperationSimulator<\n C extends ClientWithAlchemyMethods\n>(client: C): ClientMiddlewareFn {\n return async (struct, { account }) => {\n const uoSimResult = await client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [\n deepHexlify(await resolveProperties(struct)),\n account.getEntryPoint().address,\n ],\n });\n\n if (uoSimResult.error) {\n throw new Error(uoSimResult.error.message);\n }\n\n return struct;\n };\n}\n"]}
1
+ {"version":3,"file":"userOperationSimulator.js","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,GAGlB,MAAM,cAAc,CAAC;AAsBtB,MAAM,UAAU,6BAA6B,CAK3C,MAAS;IACT,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACvC,MAAM,EAAE,2CAA2C;YACnD,MAAM,EAAE;gBACN,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;gBAC5C,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;aAChC;SACF,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n deepHexlify,\n resolveProperties,\n type ClientMiddlewareFn,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\n\n/**\n * A middleware function to be used during simulation of user operations which leverages Alchemy's RPC uo simulation method.\n *\n * @example\n * ```ts\n * import { alchemyUserOperationSimulator, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createAlchemyPublicRpcClient(...);\n * const client = createSmartAccountClient({\n * userOperationSimulator: alchemyUserOperationSimulator(bundlerClient),\n * ...otherParams\n * });\n * ```\n *\n * @template C The client object with Alchemy methods\n * @param {C} client The client object with Alchemy methods\n * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations\n */\nexport function alchemyUserOperationSimulator<\n C extends ClientWithAlchemyMethods,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(client: C): ClientMiddlewareFn<TContext> {\n return async (struct, { account }) => {\n const uoSimResult = await client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [\n deepHexlify(await resolveProperties(struct)),\n account.getEntryPoint().address,\n ],\n });\n\n if (uoSimResult.error) {\n throw new Error(uoSimResult.error.message);\n }\n\n return struct;\n };\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.0-alpha.5";
1
+ export declare const VERSION = "4.0.0-alpha.6";
@@ -1,2 +1,2 @@
1
- export const VERSION = "4.0.0-alpha.5";
1
+ export const VERSION = "4.0.0-alpha.6";
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,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.5\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,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.6\";\n"]}
@@ -45,4 +45,6 @@ export declare const fraxtal: Chain;
45
45
  export declare const fraxtalSepolia: Chain;
46
46
  export declare const zora: Chain;
47
47
  export declare const zoraSepolia: Chain;
48
+ export declare const worldChainSepolia: Chain;
49
+ export declare const worldChain: Chain;
48
50
  //# sourceMappingURL=chains.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chains.d.ts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,MAAM,MAAM,CAAC;AAwBlC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB;WAItB,KAAK;gBACA,MAAM;MAChB,KAUH,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAQ5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAQ7B,CAAC;AACF,eAAO,MAAM,MAAM,EAAE,KAQpB,CAAC;AACF,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AACF,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AACF,eAAO,MAAM,cAAc,EAAE,KAQ5B,CAAC;AACF,eAAO,MAAM,eAAe,EAAE,KAQ7B,CAAC;AACF,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AACF,eAAO,MAAM,IAAI,EAAE,KAQlB,CAAC;AACF,eAAO,MAAM,UAAU,EAAE,KAQxB,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,KAQzB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAQ3B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAQzB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAS3B,CAAC;AAEH,eAAO,MAAM,IAAI,EAAE,KAKlB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAKzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAgB9B,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,KAgBvB,CAAC"}
@@ -12,8 +12,8 @@ export declare function getSignerTypeHeader<TAccount extends SmartContractAccoun
12
12
  * Helper method meant to be used internally to create an alchemy smart account client
13
13
  * from an existing Alchemy Rpc Client
14
14
  *
15
- * @param args configuration for the client
16
- * @returns a smart account client configured to use Alchemy's RPC
15
+ * @param {CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>} args configuration for the client
16
+ * @returns {AlchemySmartAccountClient} a smart account client configured to use Alchemy's RPC
17
17
  */
18
18
  export declare function createAlchemySmartAccountClientFromRpcClient<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(args: CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>): AlchemySmartAccountClient<CustomTransport, TChain, TAccount, Record<string, never>, TContext>;
19
19
  //# sourceMappingURL=smartAccountClientFromRpc.d.ts.map
@@ -2,7 +2,7 @@ export type * from "./actions/simulateUserOperationChanges.js";
2
2
  export { simulateUserOperationChanges } from "./actions/simulateUserOperationChanges.js";
3
3
  export type * from "./actions/types.js";
4
4
  export type * from "./chains.js";
5
- export { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, zora, zoraSepolia, } from "./chains.js";
5
+ export { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, zora, zoraSepolia, worldChain, worldChainSepolia, } from "./chains.js";
6
6
  export type * from "./client/decorators/alchemyEnhancedApis.js";
7
7
  export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
8
8
  export type * from "./client/decorators/smartAccount.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,2CAA2C,CAAC;AAC/D,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AAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,mBAAmB,aAAa,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC"}
@@ -86,9 +86,9 @@ export interface AlchemyGasEstimationOptions {
86
86
  * Alchemy gas manager middleware used as the paymaster middleware overrides param to the client middleware config
87
87
  *
88
88
  * @template {ClientWithAlchemyMethods} C
89
- * @param client client with alchemy methods
90
- * @param config alchemy gas manager configuration
91
- * @returns the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager
89
+ * @param {ClientWithAlchemyMethods} client client with alchemy methods
90
+ * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration
91
+ * @returns {Pick<ClientMiddlewareConfig,"paymasterAndData" | "feeEstimator" | "gasEstimator">} the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager
92
92
  */
93
93
  export declare function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(client: C, config: AlchemyGasManagerConfig): Pick<ClientMiddlewareConfig, "paymasterAndData" | "feeEstimator" | "gasEstimator">;
94
94
  //# sourceMappingURL=gasManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gasManager.d.ts","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EAGV,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAA0B,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAIhE;;;;GAIG;AACH,MAAM,MAAM,sCAAsC,CAChD,kBAAkB,SAAS,iBAAiB,GAAG,iBAAiB,IAC9D,OAAO,CACT;IACE,YAAY,EACR,oBAAoB,CAAC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GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,kBAAkB,CAAC;IAC1C;;;OAGG;IACH,qBAAqB,CAAC,EAAE,kBAAkB,CAAC;CAC5C;AAgCD;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,wBAAwB,EAC5E,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,uBAAuB,GAC9B,IAAI,CACL,sBAAsB,EACtB,kBAAkB,GAAG,cAAc,GAAG,cAAc,CACrD,CA6DA"}
@@ -1,4 +1,4 @@
1
- import { type ClientMiddlewareFn } from "@aa-sdk/core";
1
+ import { type ClientMiddlewareFn, type UserOperationContext } from "@aa-sdk/core";
2
2
  import type { ClientWithAlchemyMethods } from "../client/types";
3
3
  /**
4
4
  * A middleware function to be used during simulation of user operations which leverages Alchemy's RPC uo simulation method.
@@ -19,5 +19,5 @@ import type { ClientWithAlchemyMethods } from "../client/types";
19
19
  * @param {C} client The client object with Alchemy methods
20
20
  * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations
21
21
  */
22
- export declare function alchemyUserOperationSimulator<C extends ClientWithAlchemyMethods>(client: C): ClientMiddlewareFn;
22
+ export declare function alchemyUserOperationSimulator<C extends ClientWithAlchemyMethods, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: C): ClientMiddlewareFn<TContext>;
23
23
  //# sourceMappingURL=userOperationSimulator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"userOperationSimulator.d.ts","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,CAC3C,CAAC,SAAS,wBAAwB,EAClC,MAAM,EAAE,CAAC,GAAG,kBAAkB,CAgB/B"}
1
+ {"version":3,"file":"userOperationSimulator.d.ts","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,CAC3C,CAAC,SAAS,wBAAwB,EAClC,QAAQ,SAAS,oBAAoB,GAAG,SAAS,GAC7C,oBAAoB,GACpB,SAAS,EACb,MAAM,EAAE,CAAC,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAgBzC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.0.0-alpha.5";
1
+ export declare const VERSION = "4.0.0-alpha.6";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@account-kit/infra",
3
- "version": "4.0.0-alpha.5",
3
+ "version": "4.0.0-alpha.6",
4
4
  "description": "adapters for @aa-sdk/core for interacting with alchemy services",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -34,6 +34,7 @@
34
34
  "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
35
35
  "build:esm": "tsc --project tsconfig.build.json --module es2020 --outDir ./dist/esm --removeComments && echo > ./dist/esm/package.json '{\"type\":\"module\"}'",
36
36
  "build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
37
+ "docs:gen": "npx ak-docgen generate --in ./src/index.ts --out ../../site/pages/reference/account-kit/infra",
37
38
  "clean": "rm -rf ./dist",
38
39
  "test": "vitest",
39
40
  "test:run": "vitest run",
@@ -45,7 +46,7 @@
45
46
  "vitest": "^0.31.0"
46
47
  },
47
48
  "dependencies": {
48
- "@aa-sdk/core": "^4.0.0-alpha.5",
49
+ "@aa-sdk/core": "^4.0.0-alpha.6",
49
50
  "eventemitter3": "^5.0.1",
50
51
  "viem": "2.8.6",
51
52
  "zod": "^3.22.4"
@@ -68,7 +69,7 @@
68
69
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
69
70
  },
70
71
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
71
- "gitHead": "674bcb173cab611f7738ddc804a48846ea19f958",
72
+ "gitHead": "2c35ec701f526c77ea5e00e2e6f147156c7ac0e4",
72
73
  "optionalDependencies": {
73
74
  "alchemy-sdk": "^3.0.0"
74
75
  }
package/src/chains.ts CHANGED
@@ -236,3 +236,39 @@ export const zoraSepolia: Chain = {
236
236
  ...vzoras.rpcUrls,
237
237
  },
238
238
  };
239
+
240
+ export const worldChainSepolia: Chain = defineChain({
241
+ id: 4801,
242
+ name: "World Chain Sepolia",
243
+ network: "World Chain Sepolia",
244
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
245
+ rpcUrls: {
246
+ default: {
247
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
248
+ },
249
+ public: {
250
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
251
+ },
252
+ alchemy: {
253
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
254
+ },
255
+ },
256
+ });
257
+
258
+ export const worldChain: Chain = defineChain({
259
+ id: 480,
260
+ name: "World Chain",
261
+ network: "World Chain",
262
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
263
+ rpcUrls: {
264
+ default: {
265
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
266
+ },
267
+ public: {
268
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
269
+ },
270
+ alchemy: {
271
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
272
+ },
273
+ },
274
+ });
@@ -39,8 +39,8 @@ export function getSignerTypeHeader<
39
39
  * Helper method meant to be used internally to create an alchemy smart account client
40
40
  * from an existing Alchemy Rpc Client
41
41
  *
42
- * @param args configuration for the client
43
- * @returns a smart account client configured to use Alchemy's RPC
42
+ * @param {CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>} args configuration for the client
43
+ * @returns {AlchemySmartAccountClient} a smart account client configured to use Alchemy's RPC
44
44
  */
45
45
  export function createAlchemySmartAccountClientFromRpcClient<
46
46
  TChain extends Chain | undefined = Chain | undefined,
package/src/index.ts CHANGED
@@ -23,6 +23,8 @@ export {
23
23
  sepolia,
24
24
  zora,
25
25
  zoraSepolia,
26
+ worldChain,
27
+ worldChainSepolia,
26
28
  } from "./chains.js";
27
29
  export type * from "./client/decorators/alchemyEnhancedApis.js";
28
30
  export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
@@ -147,33 +147,40 @@ export interface AlchemyGasEstimationOptions {
147
147
  /**
148
148
  * Dummy paymaster and data middleware for the alchemy gas manager
149
149
  *
150
+ * NOTE: right now, this only really works for 0.6.0 unless you pass in overrides in the config for 0.7.0
151
+ *
150
152
  * @template {ClientWithAlchemyMethods} C
151
- * @param client client with alchemy methods
152
- * @param config alchemy gas manager configuration
153
- * @returns the dummyPaymasterAndData middleware for Alchemy gas manager
153
+ * @param {ClientWithAlchemyMethods} client client with alchemy methods
154
+ * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration
155
+ * @returns {() => Hex} the dummyPaymasterAndData middleware for Alchemy gas manager
154
156
  */
155
157
  const dummyPaymasterAndData =
156
158
  <C extends ClientWithAlchemyMethods>(
157
159
  client: C,
158
160
  config: AlchemyGasManagerConfig
159
- ) =>
160
- () => {
161
+ ): ClientMiddlewareFn =>
162
+ async (uo) => {
161
163
  const paymaster =
162
164
  config.paymasterAddress ?? getAlchemyPaymasterAddress(client.chain);
163
165
  const paymasterData =
164
166
  config.dummyData ??
165
167
  "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
166
168
 
167
- return concat([paymaster, paymasterData]); // or you can also return { paymaster, paymasterData }
169
+ return {
170
+ ...uo,
171
+ paymaster,
172
+ paymasterData,
173
+ paymasterAndData: concat([paymaster, paymasterData]),
174
+ };
168
175
  };
169
176
 
170
177
  /**
171
178
  * Alchemy gas manager middleware used as the paymaster middleware overrides param to the client middleware config
172
179
  *
173
180
  * @template {ClientWithAlchemyMethods} C
174
- * @param client client with alchemy methods
175
- * @param config alchemy gas manager configuration
176
- * @returns the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager
181
+ * @param {ClientWithAlchemyMethods} client client with alchemy methods
182
+ * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration
183
+ * @returns {Pick<ClientMiddlewareConfig,"paymasterAndData" | "feeEstimator" | "gasEstimator">} the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager
177
184
  */
178
185
  export function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(
179
186
  client: C,
@@ -238,9 +245,9 @@ export function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(
238
245
  maxPriorityFeePerGas,
239
246
  };
240
247
  },
241
- paymasterAndData: disableGasEstimation
248
+ ...(disableGasEstimation
242
249
  ? requestPaymasterAndData(client, config)
243
- : requestGasAndPaymasterData(client, config),
250
+ : requestGasAndPaymasterData(client, config)),
244
251
  };
245
252
  }
246
253
 
@@ -248,11 +255,11 @@ export function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(
248
255
  * Utility function to override a field in the user operation request with the overrides or fee options
249
256
  *
250
257
  * @template {EntryPointVersion} TEntryPointVersion
251
- * @param field the field to override
252
- * @param overrides the overrides object
253
- * @param feeOptions the fee options object from the client
254
- * @param userOperation the user operation request
255
- * @returns the overridden field value
258
+ * @param {keyof UserOperationFeeOptions<TEntryPointVersion>} field the field to override
259
+ * @param {UserOperationOverrides<TEntryPointVersion> | undefined} overrides the overrides object
260
+ * @param {UserOperationFeeOptions<TEntryPointVersion> | undefined} feeOptions the fee options object from the client
261
+ * @param {UserOperationRequest<TEntryPointVersion>} userOperation the user operation request
262
+ * @returns {Hex | Multiplier | undefine} the overridden field value
256
263
  */
257
264
  const overrideField = <
258
265
  TEntryPointVersion extends EntryPointVersion = EntryPointVersion
@@ -297,17 +304,16 @@ const overrideField = <
297
304
  * that calls the [`alchemy_requestGasAndPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)
298
305
  *
299
306
  * @template {ClientWithAlchemyMethods} C
300
- * @param client client with alchemy methods
301
- * @param config alchemy gas manager configuration
302
- * @returns the paymasterAndData middleware for Alchemy gas manager
307
+ * @param {ClientWithAlchemyMethods} client client with alchemy methods
308
+ * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration
309
+ * @returns {ClientMiddlewareConfig["paymasterAndData"]} the paymasterAndData middleware for Alchemy gas manager
303
310
  */
304
311
  function requestGasAndPaymasterData<C extends ClientWithAlchemyMethods>(
305
312
  client: C,
306
313
  config: AlchemyGasManagerConfig
307
- ): ClientMiddlewareConfig["paymasterAndData"] {
314
+ ): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData"> {
308
315
  return {
309
316
  dummyPaymasterAndData: dummyPaymasterAndData(client, config),
310
-
311
317
  paymasterAndData: async (
312
318
  struct,
313
319
  { overrides: overrides_, feeOptions, account }
@@ -403,14 +409,17 @@ function requestGasAndPaymasterData<C extends ClientWithAlchemyMethods>(
403
409
  * that calls the [`alchemy_requestPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)
404
410
  * with gas estimation disabled.
405
411
  *
406
- * @param client client with alchemy methods
407
- * @param config alchemy gas manager configuration
408
- * @returns the paymasterAndData middleware for Alchemy gas manager with gas estimation disabled
412
+ * @param {ClientWithAlchemyMethods} client client with alchemy methods
413
+ * @param {AlchemyGasManagerConfig} config alchemy gas manager configuration
414
+ * @returns {ClientMiddlewareConfig["paymasterAndData"]} the paymasterAndData middleware for Alchemy gas manager with gas estimation disabled
409
415
  */
410
416
  const requestPaymasterAndData: <C extends ClientWithAlchemyMethods>(
411
417
  client: C,
412
418
  config: AlchemyGasManagerConfig
413
- ) => ClientMiddlewareConfig["paymasterAndData"] = (client, config) => ({
419
+ ) => Pick<
420
+ ClientMiddlewareConfig,
421
+ "dummyPaymasterAndData" | "paymasterAndData"
422
+ > = (client, config) => ({
414
423
  dummyPaymasterAndData: dummyPaymasterAndData(client, config),
415
424
  paymasterAndData: async (struct, { account }) => {
416
425
  const result = await client.request({
@@ -2,6 +2,7 @@ import {
2
2
  deepHexlify,
3
3
  resolveProperties,
4
4
  type ClientMiddlewareFn,
5
+ type UserOperationContext,
5
6
  } from "@aa-sdk/core";
6
7
  import type { ClientWithAlchemyMethods } from "../client/types";
7
8
 
@@ -25,8 +26,11 @@ import type { ClientWithAlchemyMethods } from "../client/types";
25
26
  * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations
26
27
  */
27
28
  export function alchemyUserOperationSimulator<
28
- C extends ClientWithAlchemyMethods
29
- >(client: C): ClientMiddlewareFn {
29
+ C extends ClientWithAlchemyMethods,
30
+ TContext extends UserOperationContext | undefined =
31
+ | UserOperationContext
32
+ | undefined
33
+ >(client: C): ClientMiddlewareFn<TContext> {
30
34
  return async (struct, { account }) => {
31
35
  const uoSimResult = await client.request({
32
36
  method: "alchemy_simulateUserOperationAssetChanges",
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.0.0-alpha.4";
3
+ export const VERSION = "4.0.0-alpha.6";