@crossmint/client-sdk-smart-wallet 0.1.21 → 0.1.23

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 (308) hide show
  1. package/dist/SmartWalletSDK.cjs +34 -1
  2. package/dist/SmartWalletSDK.cjs.map +1 -0
  3. package/dist/SmartWalletSDK.js +34 -1
  4. package/dist/SmartWalletSDK.js.map +1 -0
  5. package/dist/api/CrossmintWalletService.cjs +13 -1
  6. package/dist/api/CrossmintWalletService.cjs.map +1 -0
  7. package/dist/api/CrossmintWalletService.js +13 -1
  8. package/dist/api/CrossmintWalletService.js.map +1 -0
  9. package/dist/blockchain/chains.cjs +23 -1
  10. package/dist/blockchain/chains.cjs.map +1 -0
  11. package/dist/blockchain/chains.js +23 -1
  12. package/dist/blockchain/chains.js.map +1 -0
  13. package/dist/blockchain/rpc.cjs +11 -1
  14. package/dist/blockchain/rpc.cjs.map +1 -0
  15. package/dist/blockchain/rpc.js +11 -1
  16. package/dist/blockchain/rpc.js.map +1 -0
  17. package/dist/blockchain/transfer.cjs +7 -1
  18. package/dist/blockchain/transfer.cjs.map +1 -0
  19. package/dist/blockchain/transfer.js +7 -1
  20. package/dist/blockchain/transfer.js.map +1 -0
  21. package/dist/blockchain/wallets/EVMSmartWallet.cjs +10 -1
  22. package/dist/blockchain/wallets/EVMSmartWallet.cjs.map +1 -0
  23. package/dist/blockchain/wallets/EVMSmartWallet.js +10 -1
  24. package/dist/blockchain/wallets/EVMSmartWallet.js.map +1 -0
  25. package/dist/blockchain/wallets/SendTransactionService.cjs +11 -1
  26. package/dist/blockchain/wallets/SendTransactionService.cjs.map +1 -0
  27. package/dist/blockchain/wallets/SendTransactionService.js +11 -1
  28. package/dist/blockchain/wallets/SendTransactionService.js.map +1 -0
  29. package/dist/blockchain/wallets/account/cache.cjs +9 -1
  30. package/dist/blockchain/wallets/account/cache.cjs.map +1 -0
  31. package/dist/blockchain/wallets/account/cache.js +9 -1
  32. package/dist/blockchain/wallets/account/cache.js.map +1 -0
  33. package/dist/blockchain/wallets/account/config.cjs +9 -1
  34. package/dist/blockchain/wallets/account/config.cjs.map +1 -0
  35. package/dist/blockchain/wallets/account/config.js +9 -1
  36. package/dist/blockchain/wallets/account/config.js.map +1 -0
  37. package/dist/blockchain/wallets/account/creator.cjs +10 -1
  38. package/dist/blockchain/wallets/account/creator.cjs.map +1 -0
  39. package/dist/blockchain/wallets/account/creator.js +10 -1
  40. package/dist/blockchain/wallets/account/creator.js.map +1 -0
  41. package/dist/blockchain/wallets/account/eoa.cjs +11 -1
  42. package/dist/blockchain/wallets/account/eoa.cjs.map +1 -0
  43. package/dist/blockchain/wallets/account/eoa.js +11 -1
  44. package/dist/blockchain/wallets/account/eoa.js.map +1 -0
  45. package/dist/blockchain/wallets/account/passkey.cjs +9 -1
  46. package/dist/blockchain/wallets/account/passkey.cjs.map +1 -0
  47. package/dist/blockchain/wallets/account/passkey.js +9 -1
  48. package/dist/blockchain/wallets/account/passkey.js.map +1 -0
  49. package/dist/blockchain/wallets/account/signer.cjs +9 -1
  50. package/dist/blockchain/wallets/account/signer.cjs.map +1 -0
  51. package/dist/blockchain/wallets/account/signer.js +9 -1
  52. package/dist/blockchain/wallets/account/signer.js.map +1 -0
  53. package/dist/blockchain/wallets/account/strategy.cjs +1 -1
  54. package/dist/blockchain/wallets/account/strategy.cjs.map +1 -0
  55. package/dist/blockchain/wallets/account/strategy.js +1 -0
  56. package/dist/blockchain/wallets/account/strategy.js.map +1 -0
  57. package/dist/blockchain/wallets/clientDecorator.cjs +12 -1
  58. package/dist/blockchain/wallets/clientDecorator.cjs.map +1 -0
  59. package/dist/blockchain/wallets/clientDecorator.js +12 -1
  60. package/dist/blockchain/wallets/clientDecorator.js.map +1 -0
  61. package/dist/blockchain/wallets/index.cjs +10 -1
  62. package/dist/blockchain/wallets/index.cjs.map +1 -0
  63. package/dist/blockchain/wallets/index.js +10 -1
  64. package/dist/blockchain/wallets/index.js.map +1 -0
  65. package/dist/blockchain/wallets/paymaster.cjs +10 -1
  66. package/dist/blockchain/wallets/paymaster.cjs.map +1 -0
  67. package/dist/blockchain/wallets/paymaster.js +10 -1
  68. package/dist/blockchain/wallets/paymaster.js.map +1 -0
  69. package/dist/blockchain/wallets/service.cjs +16 -1
  70. package/dist/blockchain/wallets/service.cjs.map +1 -0
  71. package/dist/blockchain/wallets/service.js +16 -1
  72. package/dist/blockchain/wallets/service.js.map +1 -0
  73. package/dist/chunk-2HB65Y7D.js +79 -0
  74. package/dist/chunk-2HB65Y7D.js.map +1 -0
  75. package/dist/chunk-3EQHAQXO.js +112 -0
  76. package/dist/chunk-3EQHAQXO.js.map +1 -0
  77. package/dist/chunk-3R6PW6HY.js +30 -0
  78. package/dist/chunk-3R6PW6HY.js.map +1 -0
  79. package/dist/{chunk-XJGFG3RT.cjs → chunk-5MG5CIEX.cjs} +13 -1
  80. package/dist/chunk-5MG5CIEX.cjs.map +1 -0
  81. package/dist/chunk-5URMCCO6.js +9 -0
  82. package/dist/chunk-5URMCCO6.js.map +1 -0
  83. package/dist/chunk-5VHMVO22.js +39 -0
  84. package/dist/chunk-5VHMVO22.js.map +1 -0
  85. package/dist/chunk-5W4NYW72.js +44 -0
  86. package/dist/chunk-5W4NYW72.js.map +1 -0
  87. package/dist/chunk-5WVQ7J3E.cjs +369 -0
  88. package/dist/chunk-5WVQ7J3E.cjs.map +1 -0
  89. package/dist/chunk-6NJVFL2X.js +60 -0
  90. package/dist/chunk-6NJVFL2X.js.map +1 -0
  91. package/dist/chunk-77GT6B5L.cjs +79 -0
  92. package/dist/chunk-77GT6B5L.cjs.map +1 -0
  93. package/dist/chunk-7AT3QDQV.js +36 -0
  94. package/dist/chunk-7AT3QDQV.js.map +1 -0
  95. package/dist/chunk-7B2CZEJG.cjs +66 -0
  96. package/dist/chunk-7B2CZEJG.cjs.map +1 -0
  97. package/dist/chunk-7G2SBZTE.js +93 -0
  98. package/dist/chunk-7G2SBZTE.js.map +1 -0
  99. package/dist/chunk-7KTQNIAZ.cjs +112 -0
  100. package/dist/chunk-7KTQNIAZ.cjs.map +1 -0
  101. package/dist/chunk-ASIPMVRQ.js +90 -0
  102. package/dist/chunk-ASIPMVRQ.js.map +1 -0
  103. package/dist/chunk-BARW756O.js +27 -0
  104. package/dist/chunk-BARW756O.js.map +1 -0
  105. package/dist/chunk-BSFIJZ5X.js +41 -0
  106. package/dist/chunk-BSFIJZ5X.js.map +1 -0
  107. package/dist/chunk-BXSAJOIV.cjs +90 -0
  108. package/dist/chunk-BXSAJOIV.cjs.map +1 -0
  109. package/dist/chunk-C5ZRYSCP.cjs +14 -0
  110. package/dist/chunk-C5ZRYSCP.cjs.map +1 -0
  111. package/dist/chunk-DTEA33DF.cjs +59 -0
  112. package/dist/chunk-DTEA33DF.cjs.map +1 -0
  113. package/dist/chunk-DYO4HODM.cjs +36 -0
  114. package/dist/chunk-DYO4HODM.cjs.map +1 -0
  115. package/dist/chunk-EPEGJY6N.cjs +9 -0
  116. package/dist/chunk-EPEGJY6N.cjs.map +1 -0
  117. package/dist/chunk-EQSMHR77.js +30 -0
  118. package/dist/chunk-EQSMHR77.js.map +1 -0
  119. package/dist/chunk-EUQLY4SC.cjs +82 -0
  120. package/dist/chunk-EUQLY4SC.cjs.map +1 -0
  121. package/dist/chunk-FSIMJYXR.js +36 -0
  122. package/dist/chunk-FSIMJYXR.js.map +1 -0
  123. package/dist/chunk-FXGOVLZW.cjs +9 -0
  124. package/dist/chunk-FXGOVLZW.cjs.map +1 -0
  125. package/dist/chunk-GLHQIT4Q.cjs +36 -0
  126. package/dist/chunk-GLHQIT4Q.cjs.map +1 -0
  127. package/dist/chunk-IDNF4BNP.cjs +44 -0
  128. package/dist/chunk-IDNF4BNP.cjs.map +1 -0
  129. package/dist/chunk-JOB7STIS.js +9 -0
  130. package/dist/chunk-JOB7STIS.js.map +1 -0
  131. package/dist/chunk-KEY2LM72.cjs +93 -0
  132. package/dist/chunk-KEY2LM72.cjs.map +1 -0
  133. package/dist/chunk-KHROQTVY.js +1 -0
  134. package/dist/chunk-KHROQTVY.js.map +1 -0
  135. package/dist/chunk-MAID7XYG.js +14 -0
  136. package/dist/chunk-MAID7XYG.js.map +1 -0
  137. package/dist/chunk-MJZ2DXMN.cjs +123 -0
  138. package/dist/chunk-MJZ2DXMN.cjs.map +1 -0
  139. package/dist/chunk-N6DG5EZG.cjs +156 -0
  140. package/dist/chunk-N6DG5EZG.cjs.map +1 -0
  141. package/dist/chunk-NXDZHR5C.js +99 -0
  142. package/dist/chunk-NXDZHR5C.js.map +1 -0
  143. package/dist/chunk-O6IFYHDP.cjs +36 -0
  144. package/dist/chunk-O6IFYHDP.cjs.map +1 -0
  145. package/dist/chunk-OCG67QSU.cjs +41 -0
  146. package/dist/chunk-OCG67QSU.cjs.map +1 -0
  147. package/dist/chunk-OGA3YDWS.cjs +112 -0
  148. package/dist/chunk-OGA3YDWS.cjs.map +1 -0
  149. package/dist/chunk-ON4DOYVD.js +369 -0
  150. package/dist/chunk-ON4DOYVD.js.map +1 -0
  151. package/dist/chunk-OYKL3RNL.js +66 -0
  152. package/dist/chunk-OYKL3RNL.js.map +1 -0
  153. package/dist/chunk-PVFA6PBX.cjs +60 -0
  154. package/dist/chunk-PVFA6PBX.cjs.map +1 -0
  155. package/dist/chunk-QJ3BSVGV.js +36 -0
  156. package/dist/chunk-QJ3BSVGV.js.map +1 -0
  157. package/dist/chunk-RB4JSPZH.cjs +99 -0
  158. package/dist/chunk-RB4JSPZH.cjs.map +1 -0
  159. package/dist/chunk-SMDX2MXU.js +13 -0
  160. package/dist/chunk-SMDX2MXU.js.map +1 -0
  161. package/dist/chunk-TDJDKTRS.js +156 -0
  162. package/dist/chunk-TDJDKTRS.js.map +1 -0
  163. package/dist/chunk-TK3ZLI22.cjs +39 -0
  164. package/dist/chunk-TK3ZLI22.cjs.map +1 -0
  165. package/dist/chunk-TUVECZA7.cjs +22 -0
  166. package/dist/chunk-TUVECZA7.cjs.map +1 -0
  167. package/dist/chunk-U4OBHCIP.js +59 -0
  168. package/dist/chunk-U4OBHCIP.js.map +1 -0
  169. package/dist/chunk-UDDYHPSW.js +22 -0
  170. package/dist/chunk-UDDYHPSW.js.map +1 -0
  171. package/dist/chunk-UNP5V2AB.js +82 -0
  172. package/dist/chunk-UNP5V2AB.js.map +1 -0
  173. package/dist/chunk-UQKE6R5W.cjs +27 -0
  174. package/dist/chunk-UQKE6R5W.cjs.map +1 -0
  175. package/dist/chunk-UZGHOTKZ.js +112 -0
  176. package/dist/chunk-UZGHOTKZ.js.map +1 -0
  177. package/dist/chunk-XZTGDSSL.js +123 -0
  178. package/dist/chunk-XZTGDSSL.js.map +1 -0
  179. package/dist/chunk-YWCXHOSD.cjs +30 -0
  180. package/dist/chunk-YWCXHOSD.cjs.map +1 -0
  181. package/dist/chunk-ZN42AA2G.cjs +1 -0
  182. package/dist/chunk-ZN42AA2G.cjs.map +1 -0
  183. package/dist/chunk-ZOXKITU4.cjs +30 -0
  184. package/dist/chunk-ZOXKITU4.cjs.map +1 -0
  185. package/dist/error/index.cjs +25 -1
  186. package/dist/error/index.cjs.map +1 -0
  187. package/dist/error/index.js +25 -1
  188. package/dist/error/index.js.map +1 -0
  189. package/dist/error/processor.cjs +9 -1
  190. package/dist/error/processor.cjs.map +1 -0
  191. package/dist/error/processor.js +9 -1
  192. package/dist/error/processor.js.map +1 -0
  193. package/dist/index.cjs +86 -1
  194. package/dist/index.cjs.map +1 -0
  195. package/dist/index.js +86 -1
  196. package/dist/index.js.map +1 -0
  197. package/dist/services/index.cjs +11 -1
  198. package/dist/services/index.cjs.map +1 -0
  199. package/dist/services/index.js +11 -1
  200. package/dist/services/index.js.map +1 -0
  201. package/dist/services/logger.cjs +10 -1
  202. package/dist/services/logger.cjs.map +1 -0
  203. package/dist/services/logger.js +10 -1
  204. package/dist/services/logger.js.map +1 -0
  205. package/dist/types/internal.cjs +18 -1
  206. package/dist/types/internal.cjs.map +1 -0
  207. package/dist/types/internal.js +18 -1
  208. package/dist/types/internal.js.map +1 -0
  209. package/dist/types/params.cjs +1 -1
  210. package/dist/types/params.cjs.map +1 -0
  211. package/dist/types/params.js +1 -0
  212. package/dist/types/params.js.map +1 -0
  213. package/dist/types/schema.cjs +16 -1
  214. package/dist/types/schema.cjs.map +1 -0
  215. package/dist/types/schema.js +16 -1
  216. package/dist/types/schema.js.map +1 -0
  217. package/dist/types/service.cjs +1 -1
  218. package/dist/types/service.cjs.map +1 -0
  219. package/dist/types/service.js +1 -0
  220. package/dist/types/service.js.map +1 -0
  221. package/dist/types/token.cjs +1 -1
  222. package/dist/types/token.cjs.map +1 -0
  223. package/dist/types/token.js +1 -0
  224. package/dist/types/token.js.map +1 -0
  225. package/dist/utils/api.cjs +9 -1
  226. package/dist/utils/api.cjs.map +1 -0
  227. package/dist/utils/api.js +9 -1
  228. package/dist/utils/api.js.map +1 -0
  229. package/dist/utils/blockchain.cjs +7 -1
  230. package/dist/utils/blockchain.cjs.map +1 -0
  231. package/dist/utils/blockchain.js +7 -1
  232. package/dist/utils/blockchain.js.map +1 -0
  233. package/dist/utils/constants.cjs +19 -1
  234. package/dist/utils/constants.cjs.map +1 -0
  235. package/dist/utils/constants.js +19 -1
  236. package/dist/utils/constants.js.map +1 -0
  237. package/dist/utils/environment.cjs +7 -1
  238. package/dist/utils/environment.cjs.map +1 -0
  239. package/dist/utils/environment.js +7 -1
  240. package/dist/utils/environment.js.map +1 -0
  241. package/dist/utils/helpers.cjs +9 -1
  242. package/dist/utils/helpers.cjs.map +1 -0
  243. package/dist/utils/helpers.js +9 -1
  244. package/dist/utils/helpers.js.map +1 -0
  245. package/dist/utils/signer.cjs +10 -1
  246. package/dist/utils/signer.cjs.map +1 -0
  247. package/dist/utils/signer.js +10 -1
  248. package/dist/utils/signer.js.map +1 -0
  249. package/dist/utils/test.cjs +27 -1
  250. package/dist/utils/test.cjs.map +1 -0
  251. package/dist/utils/test.js +27 -1
  252. package/dist/utils/test.js.map +1 -0
  253. package/package.json +4 -4
  254. package/dist/chunk-27US7ZBX.js +0 -1
  255. package/dist/chunk-2GS5TXEY.cjs +0 -1
  256. package/dist/chunk-2R6HK64N.cjs +0 -1
  257. package/dist/chunk-3F6P4HUZ.js +0 -1
  258. package/dist/chunk-4SPA557P.js +0 -0
  259. package/dist/chunk-5M3MSPHK.cjs +0 -1
  260. package/dist/chunk-6DE5YEO5.cjs +0 -1
  261. package/dist/chunk-7AVDZZGD.cjs +0 -1
  262. package/dist/chunk-7FXFOOQU.cjs +0 -1
  263. package/dist/chunk-7JAT6GQU.js +0 -1
  264. package/dist/chunk-ATQ4WGCW.js +0 -1
  265. package/dist/chunk-B3LJJZXD.cjs +0 -2
  266. package/dist/chunk-BJZQA5VC.js +0 -1
  267. package/dist/chunk-BXXREMNR.cjs +0 -1
  268. package/dist/chunk-C3VZY7VJ.js +0 -1
  269. package/dist/chunk-CPYNP4XI.js +0 -1
  270. package/dist/chunk-CUTQYF3F.js +0 -1
  271. package/dist/chunk-D4NDUT36.js +0 -1
  272. package/dist/chunk-DIDKPOO2.cjs +0 -1
  273. package/dist/chunk-ETVJGLNY.js +0 -1
  274. package/dist/chunk-FHNNZVNU.js +0 -1
  275. package/dist/chunk-FIJ3CBJ4.js +0 -3
  276. package/dist/chunk-G57LROTD.js +0 -1
  277. package/dist/chunk-GB35YMN4.cjs +0 -1
  278. package/dist/chunk-H4CMXNVK.js +0 -1
  279. package/dist/chunk-IQTGPM2U.cjs +0 -1
  280. package/dist/chunk-KYPTGHC6.cjs +0 -1
  281. package/dist/chunk-LMVY4C4Y.js +0 -1
  282. package/dist/chunk-M4K3IZTT.cjs +0 -1
  283. package/dist/chunk-NLGILHJS.js +0 -1
  284. package/dist/chunk-O2ACORII.cjs +0 -1
  285. package/dist/chunk-OCJYX5QF.cjs +0 -1
  286. package/dist/chunk-ODAUWGUU.cjs +0 -1
  287. package/dist/chunk-PBUJXVQT.js +0 -1
  288. package/dist/chunk-PLRQBDYS.cjs +0 -1
  289. package/dist/chunk-PPTSNCSQ.cjs +0 -1
  290. package/dist/chunk-PZ6Q22YJ.js +0 -1
  291. package/dist/chunk-Q44P7MO7.cjs +0 -1
  292. package/dist/chunk-QVB3HE6Q.js +0 -2
  293. package/dist/chunk-S2XBSAGM.js +0 -1
  294. package/dist/chunk-SCXFZMLR.cjs +0 -1
  295. package/dist/chunk-STH2LE35.cjs +0 -1
  296. package/dist/chunk-SWWOVT47.cjs +0 -1
  297. package/dist/chunk-TZG6MROQ.js +0 -1
  298. package/dist/chunk-UG47CBKR.js +0 -1
  299. package/dist/chunk-UPURFW46.js +0 -1
  300. package/dist/chunk-WDM7PN4O.js +0 -1
  301. package/dist/chunk-WJ6XJMRD.cjs +0 -1
  302. package/dist/chunk-WTPE2I2Q.cjs +0 -1
  303. package/dist/chunk-XHSA4YTO.cjs +0 -3
  304. package/dist/chunk-XP6ESWVJ.js +0 -1
  305. package/dist/chunk-XQ2K2K23.cjs +0 -1
  306. package/dist/chunk-YBHSEZMB.js +0 -1
  307. package/dist/chunk-YZQJV2KA.cjs +0 -1
  308. package/dist/chunk-Z22H3MJS.js +0 -1
@@ -0,0 +1,36 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkFXGOVLZWcjs = require('./chunk-FXGOVLZW.cjs');
4
+
5
+ // src/blockchain/wallets/paymaster.ts
6
+ function usePaymaster(chain) {
7
+ return !_chunkFXGOVLZWcjs.usesGelatoBundler.call(void 0, chain);
8
+ }
9
+ function paymasterMiddleware({
10
+ bundlerClient,
11
+ entryPoint,
12
+ chain,
13
+ walletService,
14
+ user
15
+ }) {
16
+ return {
17
+ middleware: {
18
+ gasPrice: async () => (await bundlerClient.getUserOperationGasPrice()).fast,
19
+ sponsorUserOperation: async ({ userOperation }) => {
20
+ const { sponsorUserOpParams } = await walletService.sponsorUserOperation(
21
+ user,
22
+ userOperation,
23
+ entryPoint,
24
+ chain
25
+ );
26
+ return sponsorUserOpParams;
27
+ }
28
+ }
29
+ };
30
+ }
31
+
32
+
33
+
34
+
35
+ exports.usePaymaster = usePaymaster; exports.paymasterMiddleware = paymasterMiddleware;
36
+ //# sourceMappingURL=chunk-DYO4HODM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/blockchain/wallets/paymaster.ts"],"names":[],"mappings":";;;;;AASO,SAAS,aAAa,OAAyB;AAClD,SAAO,CAAC,kBAAkB,KAAK;AACnC;AAEO,SAAS,oBAAoB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,GAM2B;AACvB,SAAO;AAAA,IACH,YAAY;AAAA,MACR,UAAU,aAAa,MAAM,cAAc,yBAAyB,GAAG;AAAA,MACvE,sBAAsB,OAAO,EAAE,cAAc,MAAM;AAC/C,cAAM,EAAE,oBAAoB,IAAI,MAAM,cAAc;AAAA,UAChD;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACJ;AACA,eAAO;AAAA,MACX;AAAA,IACJ;AAAA,EACJ;AACJ","sourcesContent":["import type { CrossmintWalletService } from \"@/api/CrossmintWalletService\";\nimport type { Middleware } from \"permissionless/actions/smartAccount\";\nimport type { PimlicoBundlerClient } from \"permissionless/clients/pimlico\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\n\nimport type { UserParams } from \"../../types/params\";\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport type { SmartWalletChain } from \"../chains\";\n\nexport function usePaymaster(chain: SmartWalletChain) {\n return !usesGelatoBundler(chain);\n}\n\nexport function paymasterMiddleware({\n bundlerClient,\n entryPoint,\n chain,\n walletService,\n user,\n}: {\n bundlerClient: PimlicoBundlerClient<EntryPoint>;\n entryPoint: EntryPoint;\n chain: SmartWalletChain;\n walletService: CrossmintWalletService;\n user: UserParams;\n}): Middleware<EntryPoint> {\n return {\n middleware: {\n gasPrice: async () => (await bundlerClient.getUserOperationGasPrice()).fast,\n sponsorUserOperation: async ({ userOperation }) => {\n const { sponsorUserOpParams } = await walletService.sponsorUserOperation(\n user,\n userOperation,\n entryPoint,\n chain\n );\n return sponsorUserOpParams;\n },\n },\n };\n}\n"]}
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/environment.ts
2
+ function isClient() {
3
+ return typeof window !== "undefined";
4
+ }
5
+
6
+
7
+
8
+ exports.isClient = isClient;
9
+ //# sourceMappingURL=chunk-EPEGJY6N.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/environment.ts"],"names":[],"mappings":";AAAO,SAAS,WAAW;AACvB,SAAO,OAAO,WAAW;AAC7B","sourcesContent":["export function isClient() {\n return typeof window !== \"undefined\";\n}\n"]}
@@ -0,0 +1,30 @@
1
+ import {
2
+ SmartWalletError
3
+ } from "./chunk-ASIPMVRQ.js";
4
+
5
+ // src/utils/signer.ts
6
+ import { providerToSmartAccountSigner } from "permissionless";
7
+ async function createOwnerSigner({
8
+ walletParams
9
+ }) {
10
+ if (isEIP1193Provider(walletParams.signer)) {
11
+ return await providerToSmartAccountSigner(walletParams.signer);
12
+ } else if (isAccount(walletParams.signer)) {
13
+ return walletParams.signer.account;
14
+ } else {
15
+ const signer = walletParams.signer;
16
+ throw new SmartWalletError(`The signer type ${signer.type} is not supported`);
17
+ }
18
+ }
19
+ function isEIP1193Provider(signer) {
20
+ return signer && typeof signer.request === "function";
21
+ }
22
+ function isAccount(signer) {
23
+ return signer && signer.type === "VIEM_ACCOUNT";
24
+ }
25
+
26
+ export {
27
+ createOwnerSigner,
28
+ isAccount
29
+ };
30
+ //# sourceMappingURL=chunk-EQSMHR77.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/signer.ts"],"sourcesContent":["import { providerToSmartAccountSigner } from \"permissionless\";\nimport type { SmartAccountSigner } from \"permissionless/accounts\";\nimport type { Address, EIP1193Provider } from \"viem\";\n\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport { SmartWalletError } from \"../error\";\nimport type { ViemAccount, WalletParams } from \"../types/params\";\n\ntype CreateOwnerSignerInput = {\n chain: SmartWalletChain;\n walletParams: WalletParams;\n};\n\nexport async function createOwnerSigner({\n walletParams,\n}: CreateOwnerSignerInput): Promise<SmartAccountSigner<\"custom\", Address>> {\n if (isEIP1193Provider(walletParams.signer)) {\n return await providerToSmartAccountSigner(walletParams.signer);\n } else if (isAccount(walletParams.signer)) {\n return walletParams.signer.account;\n } else {\n const signer = walletParams.signer as any;\n throw new SmartWalletError(`The signer type ${signer.type} is not supported`);\n }\n}\n\nfunction isEIP1193Provider(signer: any): signer is EIP1193Provider {\n return signer && typeof signer.request === \"function\";\n}\n\nexport function isAccount(signer: any): signer is ViemAccount {\n return signer && signer.type === \"VIEM_ACCOUNT\";\n}\n"],"mappings":";;;;;AAAA,SAAS,oCAAoC;AAa7C,eAAsB,kBAAkB;AAAA,EACpC;AACJ,GAA2E;AACvE,MAAI,kBAAkB,aAAa,MAAM,GAAG;AACxC,WAAO,MAAM,6BAA6B,aAAa,MAAM;AAAA,EACjE,WAAW,UAAU,aAAa,MAAM,GAAG;AACvC,WAAO,aAAa,OAAO;AAAA,EAC/B,OAAO;AACH,UAAM,SAAS,aAAa;AAC5B,UAAM,IAAI,iBAAiB,mBAAmB,OAAO,IAAI,mBAAmB;AAAA,EAChF;AACJ;AAEA,SAAS,kBAAkB,QAAwC;AAC/D,SAAO,UAAU,OAAO,OAAO,YAAY;AAC/C;AAEO,SAAS,UAAU,QAAoC;AAC1D,SAAO,UAAU,OAAO,SAAS;AACrC;","names":[]}
@@ -0,0 +1,82 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkC5ZRYSCPcjs = require('./chunk-C5ZRYSCP.cjs');
4
+
5
+
6
+ var _chunk7B2CZEJGcjs = require('./chunk-7B2CZEJG.cjs');
7
+
8
+
9
+
10
+ var _chunkO6IFYHDPcjs = require('./chunk-O6IFYHDP.cjs');
11
+
12
+
13
+ var _chunkTUVECZA7cjs = require('./chunk-TUVECZA7.cjs');
14
+
15
+
16
+
17
+
18
+ var _chunkBXSAJOIVcjs = require('./chunk-BXSAJOIV.cjs');
19
+
20
+ // src/api/CrossmintWalletService.ts
21
+ var _clientsdkbase = require('@crossmint/client-sdk-base');
22
+ var _commonsdkbase = require('@crossmint/common-sdk-base');
23
+ var CrossmintWalletService = class extends _clientsdkbase.BaseCrossmintService {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.logger = _chunkC5ZRYSCPcjs.scwLogger;
27
+ this.apiErrorService = new (0, _clientsdkbase.APIErrorService)({
28
+ ERROR_USER_WALLET_ALREADY_CREATED: ({ userId }) => new (0, _chunkBXSAJOIVcjs.UserWalletAlreadyCreatedError)(userId),
29
+ ERROR_ADMIN_SIGNER_ALREADY_USED: () => new (0, _chunkBXSAJOIVcjs.AdminAlreadyUsedError)(),
30
+ ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: () => new (0, _chunkBXSAJOIVcjs.SmartWalletsNotEnabledError)()
31
+ });
32
+ }
33
+ async idempotentCreateSmartWallet(user, input) {
34
+ await this.fetchCrossmintAPI(
35
+ `${_chunkTUVECZA7cjs.API_VERSION}/sdk/smart-wallet`,
36
+ { method: "PUT", body: JSON.stringify(input) },
37
+ "Error creating abstract wallet. Please contact support",
38
+ user.jwt
39
+ );
40
+ }
41
+ async sponsorUserOperation(user, userOp, entryPoint, chain) {
42
+ const chainId = _commonsdkbase.blockchainToChainId.call(void 0, chain);
43
+ const result = await this.fetchCrossmintAPI(
44
+ `${_chunkTUVECZA7cjs.API_VERSION}/sdk/paymaster`,
45
+ { method: "POST", body: JSON.stringify({ userOp: _chunkO6IFYHDPcjs.bigintsToHex.call(void 0, userOp), entryPoint, chainId }) },
46
+ "Error sponsoring user operation. Please contact support",
47
+ user.jwt
48
+ );
49
+ return _chunkO6IFYHDPcjs.parseBigintAPIResponse.call(void 0, result);
50
+ }
51
+ async getSmartWalletConfig(user, chain) {
52
+ const data = await this.fetchCrossmintAPI(
53
+ `${_chunkTUVECZA7cjs.API_VERSION}/sdk/smart-wallet/config?chain=${chain}`,
54
+ { method: "GET" },
55
+ "Error getting smart wallet version configuration. Please contact support",
56
+ user.jwt
57
+ );
58
+ const result = _chunk7B2CZEJGcjs.SmartWalletConfigSchema.safeParse(data);
59
+ if (!result.success) {
60
+ throw new (0, _clientsdkbase.CrossmintServiceError)(
61
+ `Invalid smart wallet config, please contact support. Details below:
62
+ ${result.error.toString()}`
63
+ );
64
+ }
65
+ return result.data;
66
+ }
67
+ async fetchNFTs(address, chain) {
68
+ return this.fetchCrossmintAPI(
69
+ `v1-alpha1/wallets/${chain}:${address}/nfts`,
70
+ { method: "GET" },
71
+ `Error fetching NFTs for wallet: ${address}`
72
+ );
73
+ }
74
+ getPasskeyServerUrl() {
75
+ return this.crossmintBaseUrl + "api/internal/passkeys";
76
+ }
77
+ };
78
+
79
+
80
+
81
+ exports.CrossmintWalletService = CrossmintWalletService;
82
+ //# sourceMappingURL=chunk-EUQLY4SC.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/api/CrossmintWalletService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,SAAS,iBAAiB,sBAAsB,6BAA6B;AAC7E,SAAS,2BAA2B;AAgB7B,IAAM,yBAAN,cAAqC,qBAAqB;AAAA,EAA1D;AAAA;AACH,kBAAS;AACT,SAAU,kBAAkB,IAAI,gBAAsC;AAAA,MAClE,mCAAmC,CAAC,EAAE,OAAO,MACzC,IAAI,8BAA8B,MAAM;AAAA,MAC5C,iCAAiC,MAAM,IAAI,sBAAsB;AAAA,MACjE,gDAAgD,MAAM,IAAI,4BAA4B;AAAA,IAC1F,CAAC;AAAA;AAAA,EAED,MAAM,4BAA4B,MAAkB,OAA8C;AAC9F,UAAM,KAAK;AAAA,MACP,GAAG,WAAW;AAAA,MACd,EAAE,QAAQ,OAAO,MAAM,KAAK,UAAU,KAAK,EAAE;AAAA,MAC7C;AAAA,MACA,KAAK;AAAA,IACT;AAAA,EACJ;AAAA,EAEA,MAAM,qBACF,MACA,QACA,YACA,OACwE;AACxE,UAAM,UAAU,oBAAoB,KAAK;AACzC,UAAM,SAAS,MAAM,KAAK;AAAA,MACtB,GAAG,WAAW;AAAA,MACd,EAAE,QAAQ,QAAQ,MAAM,KAAK,UAAU,EAAE,QAAQ,aAAa,MAAM,GAAG,YAAY,QAAQ,CAAC,EAAE;AAAA,MAC9F;AAAA,MACA,KAAK;AAAA,IACT;AACA,WAAO,uBAAuB,MAAM;AAAA,EACxC;AAAA,EAEA,MAAM,qBAAqB,MAAkB,OAAqD;AAC9F,UAAM,OAAgB,MAAM,KAAK;AAAA,MAC7B,GAAG,WAAW,kCAAkC,KAAK;AAAA,MACrD,EAAE,QAAQ,MAAM;AAAA,MAChB;AAAA,MACA,KAAK;AAAA,IACT;AAEA,UAAM,SAAS,wBAAwB,UAAU,IAAI;AACrD,QAAI,CAAC,OAAO,SAAS;AACjB,YAAM,IAAI;AAAA,QACN;AAAA,EAAwE,OAAO,MAAM,SAAS,CAAC;AAAA,MACnG;AAAA,IACJ;AAEA,WAAO,OAAO;AAAA,EAClB;AAAA,EAEA,MAAM,UAAU,SAAiB,OAAyB;AACtD,WAAO,KAAK;AAAA,MACR,qBAAqB,KAAK,IAAI,OAAO;AAAA,MACrC,EAAE,QAAQ,MAAM;AAAA,MAChB,mCAAmC,OAAO;AAAA,IAC9C;AAAA,EACJ;AAAA,EAEO,sBAA8B;AACjC,WAAO,KAAK,mBAAmB;AAAA,EACnC;AACJ","sourcesContent":["import type { UserOperation } from \"permissionless\";\nimport type { EntryPoint, GetEntryPointVersion } from \"permissionless/types/entrypoint\";\n\nimport { APIErrorService, BaseCrossmintService, CrossmintServiceError } from \"@crossmint/client-sdk-base\";\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport { AdminAlreadyUsedError, SmartWalletsNotEnabledError, UserWalletAlreadyCreatedError } from \"../error\";\nimport { scwLogger } from \"../services\";\nimport type { UserParams } from \"../types/params\";\nimport { SmartWalletConfigSchema } from \"../types/schema\";\nimport type { SmartWalletConfig, StoreSmartWalletParams } from \"../types/service\";\nimport { bigintsToHex, parseBigintAPIResponse } from \"../utils/api\";\nimport { API_VERSION } from \"../utils/constants\";\n\ntype WalletsAPIErrorCodes =\n | \"ERROR_USER_WALLET_ALREADY_CREATED\"\n | \"ERROR_ADMIN_SIGNER_ALREADY_USED\"\n | \"ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED\";\n\nexport class CrossmintWalletService extends BaseCrossmintService {\n logger = scwLogger;\n protected apiErrorService = new APIErrorService<WalletsAPIErrorCodes>({\n ERROR_USER_WALLET_ALREADY_CREATED: ({ userId }: { userId: string }) =>\n new UserWalletAlreadyCreatedError(userId),\n ERROR_ADMIN_SIGNER_ALREADY_USED: () => new AdminAlreadyUsedError(),\n ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: () => new SmartWalletsNotEnabledError(),\n });\n\n async idempotentCreateSmartWallet(user: UserParams, input: StoreSmartWalletParams): Promise<void> {\n await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet`,\n { method: \"PUT\", body: JSON.stringify(input) },\n \"Error creating abstract wallet. Please contact support\",\n user.jwt\n );\n }\n\n async sponsorUserOperation<E extends EntryPoint>(\n user: UserParams,\n userOp: UserOperation<GetEntryPointVersion<E>>,\n entryPoint: E,\n chain: SmartWalletChain\n ): Promise<{ sponsorUserOpParams: UserOperation<GetEntryPointVersion<E>> }> {\n const chainId = blockchainToChainId(chain);\n const result = await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/paymaster`,\n { method: \"POST\", body: JSON.stringify({ userOp: bigintsToHex(userOp), entryPoint, chainId }) },\n \"Error sponsoring user operation. Please contact support\",\n user.jwt\n );\n return parseBigintAPIResponse(result);\n }\n\n async getSmartWalletConfig(user: UserParams, chain: SmartWalletChain): Promise<SmartWalletConfig> {\n const data: unknown = await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet/config?chain=${chain}`,\n { method: \"GET\" },\n \"Error getting smart wallet version configuration. Please contact support\",\n user.jwt\n );\n\n const result = SmartWalletConfigSchema.safeParse(data);\n if (!result.success) {\n throw new CrossmintServiceError(\n `Invalid smart wallet config, please contact support. Details below:\\n${result.error.toString()}`\n );\n }\n\n return result.data;\n }\n\n async fetchNFTs(address: string, chain: SmartWalletChain) {\n return this.fetchCrossmintAPI(\n `v1-alpha1/wallets/${chain}:${address}/nfts`,\n { method: \"GET\" },\n `Error fetching NFTs for wallet: ${address}`\n );\n }\n\n public getPasskeyServerUrl(): string {\n return this.crossmintBaseUrl + \"api/internal/passkeys\";\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ // src/utils/api.ts
2
+ import { toHex } from "viem";
3
+ function mapObject(data, fn) {
4
+ const result = fn(data);
5
+ if (result.replace) {
6
+ return result.value;
7
+ }
8
+ if (Array.isArray(data)) {
9
+ return data.map((item) => mapObject(item, fn));
10
+ } else if (data !== null && typeof data === "object") {
11
+ return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, mapObject(value, fn)]));
12
+ }
13
+ return result.value;
14
+ }
15
+ function bigintsToHex(data) {
16
+ return mapObject(data, (value) => {
17
+ if (typeof value === "bigint") {
18
+ return { value: toHex(value), replace: true };
19
+ }
20
+ return { value, replace: false };
21
+ });
22
+ }
23
+ function parseBigintAPIResponse(data) {
24
+ return mapObject(data, (value) => {
25
+ if (value != null && typeof value == "object" && "__xm_serializedType" in value && "value" in value && value.__xm_serializedType === "bigint" && typeof value.value === "string") {
26
+ return { value: BigInt(value.value), replace: true };
27
+ }
28
+ return { value, replace: false };
29
+ });
30
+ }
31
+
32
+ export {
33
+ bigintsToHex,
34
+ parseBigintAPIResponse
35
+ };
36
+ //# sourceMappingURL=chunk-FSIMJYXR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/api.ts"],"sourcesContent":["import { toHex } from \"viem\";\n\nfunction mapObject(data: any, fn: (value: unknown) => { value: unknown; replace: boolean }): any {\n const result = fn(data);\n if (result.replace) {\n return result.value;\n }\n if (Array.isArray(data)) {\n return data.map((item) => mapObject(item, fn));\n } else if (data !== null && typeof data === \"object\") {\n return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, mapObject(value, fn)]));\n }\n return result.value;\n}\n\nexport function bigintsToHex(data: any): any {\n return mapObject(data, (value) => {\n if (typeof value === \"bigint\") {\n return { value: toHex(value), replace: true };\n }\n return { value, replace: false };\n });\n}\n\nexport function parseBigintAPIResponse(data: any): any {\n return mapObject(data, (value) => {\n if (\n value != null &&\n typeof value == \"object\" &&\n \"__xm_serializedType\" in value &&\n \"value\" in value &&\n value.__xm_serializedType === \"bigint\" &&\n typeof value.value === \"string\"\n ) {\n return { value: BigInt(value.value), replace: true };\n }\n return { value, replace: false };\n });\n}\n"],"mappings":";AAAA,SAAS,aAAa;AAEtB,SAAS,UAAU,MAAW,IAAmE;AAC7F,QAAM,SAAS,GAAG,IAAI;AACtB,MAAI,OAAO,SAAS;AAChB,WAAO,OAAO;AAAA,EAClB;AACA,MAAI,MAAM,QAAQ,IAAI,GAAG;AACrB,WAAO,KAAK,IAAI,CAAC,SAAS,UAAU,MAAM,EAAE,CAAC;AAAA,EACjD,WAAW,SAAS,QAAQ,OAAO,SAAS,UAAU;AAClD,WAAO,OAAO,YAAY,OAAO,QAAQ,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,EAAE,CAAC,CAAC,CAAC;AAAA,EACrG;AACA,SAAO,OAAO;AAClB;AAEO,SAAS,aAAa,MAAgB;AACzC,SAAO,UAAU,MAAM,CAAC,UAAU;AAC9B,QAAI,OAAO,UAAU,UAAU;AAC3B,aAAO,EAAE,OAAO,MAAM,KAAK,GAAG,SAAS,KAAK;AAAA,IAChD;AACA,WAAO,EAAE,OAAO,SAAS,MAAM;AAAA,EACnC,CAAC;AACL;AAEO,SAAS,uBAAuB,MAAgB;AACnD,SAAO,UAAU,MAAM,CAAC,UAAU;AAC9B,QACI,SAAS,QACT,OAAO,SAAS,YAChB,yBAAyB,SACzB,WAAW,SACX,MAAM,wBAAwB,YAC9B,OAAO,MAAM,UAAU,UACzB;AACE,aAAO,EAAE,OAAO,OAAO,MAAM,KAAK,GAAG,SAAS,KAAK;AAAA,IACvD;AACA,WAAO,EAAE,OAAO,SAAS,MAAM;AAAA,EACnC,CAAC;AACL;","names":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/blockchain.ts
2
+ function usesGelatoBundler(chain) {
3
+ return false;
4
+ }
5
+
6
+
7
+
8
+ exports.usesGelatoBundler = usesGelatoBundler;
9
+ //# sourceMappingURL=chunk-FXGOVLZW.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/blockchain.ts"],"names":[],"mappings":";AAEO,SAAS,kBAAkB,OAAyB;AACvD,SAAO;AACX","sourcesContent":["import type { SmartWalletChain } from \"../blockchain/chains\";\n\nexport function usesGelatoBundler(chain: SmartWalletChain) {\n return false;\n}\n"]}
@@ -0,0 +1,36 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkTUVECZA7cjs = require('./chunk-TUVECZA7.cjs');
5
+
6
+ // src/types/internal.ts
7
+ function isSupportedKernelVersion(version) {
8
+ return _chunkTUVECZA7cjs.SUPPORTED_KERNEL_VERSIONS.includes(version);
9
+ }
10
+ function isSupportedEntryPointVersion(version) {
11
+ return _chunkTUVECZA7cjs.SUPPORTED_ENTRYPOINT_VERSIONS.includes(version);
12
+ }
13
+ function isPasskeyWalletParams(params) {
14
+ return "signer" in params && "type" in params.signer && params.signer.type === "PASSKEY";
15
+ }
16
+ function isPasskeyCreationContext(params) {
17
+ const signerIsPasskeyOrUndefined = params.existing == null || params.existing.signerConfig.type === "passkeys";
18
+ return isPasskeyWalletParams(params.walletParams) && signerIsPasskeyOrUndefined;
19
+ }
20
+ function isEOAWalletParams(params) {
21
+ return "signer" in params && ("type" in params.signer && params.signer.type === "VIEM_ACCOUNT" || "request" in params.signer && typeof params.signer.request === "function");
22
+ }
23
+ function isEOACreationContext(params) {
24
+ const signerIsEOAOrUndefined = params.existing == null || params.existing.signerConfig.type === "eoa";
25
+ return isEOAWalletParams(params.walletParams) && signerIsEOAOrUndefined;
26
+ }
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ exports.isSupportedKernelVersion = isSupportedKernelVersion; exports.isSupportedEntryPointVersion = isSupportedEntryPointVersion; exports.isPasskeyWalletParams = isPasskeyWalletParams; exports.isPasskeyCreationContext = isPasskeyCreationContext; exports.isEOAWalletParams = isEOAWalletParams; exports.isEOACreationContext = isEOACreationContext;
36
+ //# sourceMappingURL=chunk-GLHQIT4Q.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/internal.ts"],"names":[],"mappings":";;;;;;AAYO,SAAS,yBAAyB,SAAoD;AACzF,SAAO,0BAA0B,SAAS,OAAc;AAC5D;AAGO,SAAS,6BAA6B,SAAwD;AACjG,SAAO,8BAA8B,SAAS,OAAc;AAChE;AA2BO,SAAS,sBAAsB,QAA0E;AAC5G,SAAO,YAAY,UAAU,UAAU,OAAO,UAAU,OAAO,OAAO,SAAS;AACnF;AAEO,SAAS,yBAAyB,QAAiE;AACtG,QAAM,6BAA6B,OAAO,YAAY,QAAQ,OAAO,SAAS,aAAa,SAAS;AAEpG,SAAO,sBAAsB,OAAO,YAAY,KAAK;AACzD;AAEO,SAAS,kBAAkB,QAA2E;AACzG,SACI,YAAY,WACV,UAAU,OAAO,UAAU,OAAO,OAAO,SAAS,kBAC/C,aAAa,OAAO,UAAU,OAAO,OAAO,OAAO,YAAY;AAE5E;AAEO,SAAS,qBAAqB,QAA6D;AAC9F,QAAM,yBAAyB,OAAO,YAAY,QAAQ,OAAO,SAAS,aAAa,SAAS;AAEhG,SAAO,kBAAkB,OAAO,YAAY,KAAK;AACrD","sourcesContent":["import type { KernelSmartAccount } from \"@zerodev/sdk\";\nimport type { SmartAccountClient } from \"permissionless\";\nimport type { SmartAccount } from \"permissionless/accounts\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport type { Address, Chain, HttpTransport, PublicClient } from \"viem\";\n\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport type { EOASignerConfig, PasskeySignerConfig, SignerConfig } from \"../blockchain/wallets/account/signer\";\nimport { SUPPORTED_ENTRYPOINT_VERSIONS, SUPPORTED_KERNEL_VERSIONS } from \"../utils/constants\";\nimport type { ExternalSigner, PasskeySigner, UserParams, WalletParams } from \"./params\";\n\nexport type SupportedKernelVersion = (typeof SUPPORTED_KERNEL_VERSIONS)[number];\nexport function isSupportedKernelVersion(version: string): version is SupportedKernelVersion {\n return SUPPORTED_KERNEL_VERSIONS.includes(version as any);\n}\n\nexport type SupportedEntryPointVersion = (typeof SUPPORTED_ENTRYPOINT_VERSIONS)[number];\nexport function isSupportedEntryPointVersion(version: string): version is SupportedEntryPointVersion {\n return SUPPORTED_ENTRYPOINT_VERSIONS.includes(version as any);\n}\n\nexport interface PreExistingWalletProperties {\n signerConfig: SignerConfig;\n address: Address;\n}\n\nexport interface WalletCreationContext {\n user: UserParams & { id: string };\n chain: SmartWalletChain;\n publicClient: PublicClient<HttpTransport>;\n walletParams: WalletParams;\n entryPoint: EntryPoint;\n kernelVersion: SupportedKernelVersion;\n existing?: PreExistingWalletProperties;\n}\n\nexport interface PasskeyCreationContext extends WalletCreationContext {\n walletParams: WalletParams & { signer: PasskeySigner };\n existing?: { signerConfig: PasskeySignerConfig; address: Address };\n}\n\nexport interface EOACreationContext extends WalletCreationContext {\n walletParams: WalletParams & { signer: ExternalSigner };\n existing?: { signerConfig: EOASignerConfig; address: Address };\n}\n\nexport function isPasskeyWalletParams(params: WalletParams): params is WalletParams & { signer: PasskeySigner } {\n return \"signer\" in params && \"type\" in params.signer && params.signer.type === \"PASSKEY\";\n}\n\nexport function isPasskeyCreationContext(params: WalletCreationContext): params is PasskeyCreationContext {\n const signerIsPasskeyOrUndefined = params.existing == null || params.existing.signerConfig.type === \"passkeys\";\n\n return isPasskeyWalletParams(params.walletParams) && signerIsPasskeyOrUndefined;\n}\n\nexport function isEOAWalletParams(params: WalletParams): params is WalletParams & { signer: ExternalSigner } {\n return (\n \"signer\" in params &&\n ((\"type\" in params.signer && params.signer.type === \"VIEM_ACCOUNT\") ||\n (\"request\" in params.signer && typeof params.signer.request === \"function\"))\n );\n}\n\nexport function isEOACreationContext(params: WalletCreationContext): params is EOACreationContext {\n const signerIsEOAOrUndefined = params.existing == null || params.existing.signerConfig.type === \"eoa\";\n\n return isEOAWalletParams(params.walletParams) && signerIsEOAOrUndefined;\n}\n\nexport interface AccountAndSigner {\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n signerConfig: SignerConfig;\n}\n\nexport type SmartWalletClient = SmartAccountClient<EntryPoint, HttpTransport, Chain, SmartAccount<EntryPoint>>;\n"]}
@@ -0,0 +1,44 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk7B2CZEJGcjs = require('./chunk-7B2CZEJG.cjs');
4
+
5
+ // src/blockchain/wallets/account/cache.ts
6
+ var _viem = require('viem');
7
+ var AccountConfigCache = class {
8
+ constructor(keyPrefix) {
9
+ this.keyPrefix = keyPrefix;
10
+ }
11
+ set(user, config) {
12
+ localStorage.setItem(this.key(user), JSON.stringify(config));
13
+ }
14
+ get(user) {
15
+ const key = this.key(user);
16
+ const data = localStorage.getItem(key);
17
+ if (data == null) {
18
+ return null;
19
+ }
20
+ const result = _chunk7B2CZEJGcjs.SmartWalletConfigSchema.safeParse(JSON.parse(data));
21
+ if (!result.success) {
22
+ localStorage.removeItem(key);
23
+ return null;
24
+ }
25
+ return result.data;
26
+ }
27
+ clear() {
28
+ for (let i = 0; i < localStorage.length; i++) {
29
+ const key = localStorage.key(i);
30
+ if (key && key.startsWith(this.keyPrefix)) {
31
+ localStorage.removeItem(key);
32
+ i--;
33
+ }
34
+ }
35
+ }
36
+ key(user) {
37
+ return `${this.keyPrefix}-${_viem.keccak256.call(void 0, _viem.toHex.call(void 0, user.jwt))}`;
38
+ }
39
+ };
40
+
41
+
42
+
43
+ exports.AccountConfigCache = AccountConfigCache;
44
+ //# sourceMappingURL=chunk-IDNF4BNP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/blockchain/wallets/account/cache.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,WAAW,aAAa;AAM1B,IAAM,qBAAN,MAAyB;AAAA,EAC5B,YAA6B,WAAmB;AAAnB;AAAA,EAAoB;AAAA,EAE1C,IAAI,MAAkB,QAA2B;AACpD,iBAAa,QAAQ,KAAK,IAAI,IAAI,GAAG,KAAK,UAAU,MAAM,CAAC;AAAA,EAC/D;AAAA,EAEO,IAAI,MAA4C;AACnD,UAAM,MAAM,KAAK,IAAI,IAAI;AACzB,UAAM,OAAO,aAAa,QAAQ,GAAG;AACrC,QAAI,QAAQ,MAAM;AACd,aAAO;AAAA,IACX;AAEA,UAAM,SAAS,wBAAwB,UAAU,KAAK,MAAM,IAAI,CAAC;AACjE,QAAI,CAAC,OAAO,SAAS;AACjB,mBAAa,WAAW,GAAG;AAC3B,aAAO;AAAA,IACX;AAEA,WAAO,OAAO;AAAA,EAClB;AAAA,EAEO,QAAQ;AACX,aAAS,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;AAC1C,YAAM,MAAM,aAAa,IAAI,CAAC;AAC9B,UAAI,OAAO,IAAI,WAAW,KAAK,SAAS,GAAG;AACvC,qBAAa,WAAW,GAAG;AAC3B;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAAA,EAEQ,IAAI,MAAkB;AAC1B,WAAO,GAAG,KAAK,SAAS,IAAI,UAAU,MAAM,KAAK,GAAG,CAAC,CAAC;AAAA,EAC1D;AACJ","sourcesContent":["import { keccak256, toHex } from \"viem\";\n\nimport type { UserParams } from \"../../../types/params\";\nimport { SmartWalletConfigSchema } from \"../../../types/schema\";\nimport type { SmartWalletConfig } from \"../../../types/service\";\n\nexport class AccountConfigCache {\n constructor(private readonly keyPrefix: string) {}\n\n public set(user: UserParams, config: SmartWalletConfig) {\n localStorage.setItem(this.key(user), JSON.stringify(config));\n }\n\n public get(user: UserParams): SmartWalletConfig | null {\n const key = this.key(user);\n const data = localStorage.getItem(key);\n if (data == null) {\n return null;\n }\n\n const result = SmartWalletConfigSchema.safeParse(JSON.parse(data));\n if (!result.success) {\n localStorage.removeItem(key);\n return null;\n }\n\n return result.data;\n }\n\n public clear() {\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key && key.startsWith(this.keyPrefix)) {\n localStorage.removeItem(key);\n i--; // Decrement i since we've removed an item\n }\n }\n }\n\n private key(user: UserParams) {\n return `${this.keyPrefix}-${keccak256(toHex(user.jwt))}`;\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ // src/utils/blockchain.ts
2
+ function usesGelatoBundler(chain) {
3
+ return false;
4
+ }
5
+
6
+ export {
7
+ usesGelatoBundler
8
+ };
9
+ //# sourceMappingURL=chunk-JOB7STIS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/blockchain.ts"],"sourcesContent":["import type { SmartWalletChain } from \"../blockchain/chains\";\n\nexport function usesGelatoBundler(chain: SmartWalletChain) {\n return false;\n}\n"],"mappings":";AAEO,SAAS,kBAAkB,OAAyB;AACvD,SAAO;AACX;","names":[]}
@@ -0,0 +1,93 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkFXGOVLZWcjs = require('./chunk-FXGOVLZW.cjs');
4
+
5
+
6
+ var _chunkC5ZRYSCPcjs = require('./chunk-C5ZRYSCP.cjs');
7
+
8
+
9
+ var _chunkBXSAJOIVcjs = require('./chunk-BXSAJOIV.cjs');
10
+
11
+ // src/blockchain/wallets/clientDecorator.ts
12
+ var _viem = require('viem');
13
+ var transactionMethods = [
14
+ "sendTransaction",
15
+ "writeContract",
16
+ "sendUserOperation"
17
+ ];
18
+ var signingMethods = [
19
+ "signMessage",
20
+ "signTypedData"
21
+ ];
22
+ function isTxnMethod(method) {
23
+ return transactionMethods.includes(method);
24
+ }
25
+ function isSignMethod(method) {
26
+ return signingMethods.includes(method);
27
+ }
28
+ var ClientDecorator = class {
29
+ constructor(errorProcessor, logger = _chunkC5ZRYSCPcjs.scwLogger) {
30
+ this.errorProcessor = errorProcessor;
31
+ this.logger = logger;
32
+ }
33
+ decorate({
34
+ crossmintChain,
35
+ smartAccountClient
36
+ }) {
37
+ return new Proxy(smartAccountClient, {
38
+ get: (target, prop, receiver) => {
39
+ const originalMethod = Reflect.get(target, prop, receiver);
40
+ if (typeof originalMethod !== "function" || typeof prop !== "string" || !(isSignMethod(prop) || isTxnMethod(prop))) {
41
+ return originalMethod;
42
+ }
43
+ return (...args) => this.logger.logPerformance(
44
+ `CrossmintSmartWallet.${prop}`,
45
+ () => this.execute(target, prop, originalMethod, args, crossmintChain)
46
+ );
47
+ }
48
+ });
49
+ }
50
+ async execute(target, prop, originalMethod, args, crossmintChain) {
51
+ try {
52
+ this.logger.log(`[CrossmintSmartWallet.${prop}] - params: ${_viem.stringify.call(void 0, args)}`);
53
+ const processed = isTxnMethod(prop) ? this.processTxnArgs(prop, crossmintChain, args) : args;
54
+ return await originalMethod.call(target, ...processed);
55
+ } catch (error) {
56
+ const description = isTxnMethod(prop) ? "signing" : "sending transaction";
57
+ throw this.errorProcessor.map(
58
+ error,
59
+ new (0, _chunkBXSAJOIVcjs.SmartWalletError)(`Error ${description}: ${error.message}`, _viem.stringify.call(void 0, error))
60
+ );
61
+ }
62
+ }
63
+ processTxnArgs(prop, crossmintChain, args) {
64
+ if (prop === "sendUserOperation") {
65
+ const [{ userOperation, middleware, account }] = args;
66
+ return [
67
+ {
68
+ middleware,
69
+ account,
70
+ userOperation: this.addGelatoBundlerProperties(crossmintChain, userOperation)
71
+ },
72
+ ...args.slice(1)
73
+ ];
74
+ }
75
+ const [txn] = args;
76
+ return [this.addGelatoBundlerProperties(crossmintChain, txn), ...args.slice(1)];
77
+ }
78
+ /*
79
+ * Chain that ZD uses Gelato as for bundler require special parameters:
80
+ * https://docs.zerodev.app/sdk/faqs/use-with-gelato#transaction-configuration
81
+ */
82
+ addGelatoBundlerProperties(crossmintChain, txnParams) {
83
+ if (_chunkFXGOVLZWcjs.usesGelatoBundler.call(void 0, crossmintChain)) {
84
+ return { ...txnParams, maxFeePerGas: "0x0", maxPriorityFeePerGas: "0x0" };
85
+ }
86
+ return txnParams;
87
+ }
88
+ };
89
+
90
+
91
+
92
+ exports.ClientDecorator = ClientDecorator;
93
+ //# sourceMappingURL=chunk-KEY2LM72.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/blockchain/wallets/clientDecorator.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,SAAS,iBAAiB;AAQ1B,IAAM,qBAAqB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AACJ;AAEA,IAAM,iBAAiB;AAAA,EACnB;AAAA,EACA;AACJ;AAKA,SAAS,YAAY,QAAqC;AACtD,SAAO,mBAAmB,SAAS,MAAa;AACpD;AAEA,SAAS,aAAa,QAAsC;AACxD,SAAO,eAAe,SAAS,MAAa;AAChD;AAQO,IAAM,kBAAN,MAAsB;AAAA,EACzB,YACqB,gBACP,SAAS,WACrB;AAFmB;AACP;AAAA,EACX;AAAA,EAEI,SAAwD;AAAA,IAC3D;AAAA,IACA;AAAA,EACJ,GAGW;AACP,WAAO,IAAI,MAAM,oBAAoB;AAAA,MACjC,KAAK,CAAC,QAAQ,MAAM,aAAa;AAC7B,cAAM,iBAAiB,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAEzD,YACI,OAAO,mBAAmB,cAC1B,OAAO,SAAS,YAChB,EAAE,aAAa,IAAI,KAAK,YAAY,IAAI,IAC1C;AACE,iBAAO;AAAA,QACX;AAEA,eAAO,IAAI,SACP,KAAK,OAAO;AAAA,UAAe,wBAAwB,IAAI;AAAA,UAAI,MACvD,KAAK,QAAQ,QAAQ,MAAM,gBAAgB,MAAM,cAAc;AAAA,QACnE;AAAA,MACR;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,MAAc,QACV,QACA,MACA,gBACA,MACA,gBACF;AACE,QAAI;AACA,WAAK,OAAO,IAAI,yBAAyB,IAAI,eAAe,UAAU,IAAI,CAAC,EAAE;AAC7E,YAAM,YAAY,YAAY,IAAI,IAAI,KAAK,eAAe,MAAM,gBAAgB,IAAI,IAAI;AACxF,aAAO,MAAM,eAAe,KAAK,QAAQ,GAAG,SAAS;AAAA,IACzD,SAAS,OAAY;AACjB,YAAM,cAAc,YAAY,IAAI,IAAI,YAAY;AACpD,YAAM,KAAK,eAAe;AAAA,QACtB;AAAA,QACA,IAAI,iBAAiB,SAAS,WAAW,KAAK,MAAM,OAAO,IAAI,UAAU,KAAK,CAAC;AAAA,MACnF;AAAA,IACJ;AAAA,EACJ;AAAA,EAEQ,eAAe,MAAiB,gBAAkC,MAAoB;AAC1F,QAAI,SAAS,qBAAqB;AAC9B,YAAM,CAAC,EAAE,eAAe,YAAY,QAAQ,CAAC,IAAI;AAGjD,aAAO;AAAA,QACH;AAAA,UACI;AAAA,UACA;AAAA,UACA,eAAe,KAAK,2BAA2B,gBAAgB,aAAa;AAAA,QAChF;AAAA,QACA,GAAG,KAAK,MAAM,CAAC;AAAA,MACnB;AAAA,IACJ;AAEA,UAAM,CAAC,GAAG,IAAI;AAId,WAAO,CAAC,KAAK,2BAA2B,gBAAgB,GAAG,GAAG,GAAG,KAAK,MAAM,CAAC,CAAC;AAAA,EAClF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,2BACJ,gBACA,WACF;AACE,QAAI,kBAAkB,cAAc,GAAG;AACnC,aAAO,EAAE,GAAG,WAAW,cAAc,OAAc,sBAAsB,MAAa;AAAA,IAC1F;AAEA,WAAO;AAAA,EACX;AACJ","sourcesContent":["import type { SmartAccountClient } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { stringify } from \"viem\";\n\nimport { SmartWalletError } from \"../../error\";\nimport type { ErrorProcessor } from \"../../error/processor\";\nimport { scwLogger } from \"../../services\";\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport type { SmartWalletChain } from \"../chains\";\n\nconst transactionMethods = [\n \"sendTransaction\",\n \"writeContract\",\n \"sendUserOperation\",\n] as const satisfies readonly (keyof SmartAccountClient<EntryPoint>)[];\n\nconst signingMethods = [\n \"signMessage\",\n \"signTypedData\",\n] as const satisfies readonly (keyof SmartAccountClient<EntryPoint>)[];\n\ntype TxnMethod = (typeof transactionMethods)[number];\ntype SignMethod = (typeof signingMethods)[number];\n\nfunction isTxnMethod(method: string): method is TxnMethod {\n return transactionMethods.includes(method as any);\n}\n\nfunction isSignMethod(method: string): method is SignMethod {\n return signingMethods.includes(method as any);\n}\n\n/**\n * A decorator class for SmartAccountClient instances. It enhances the client with:\n * - Error handling & logging.\n * - Performance metrics.\n * - Automatic formatting of transactions for Gelato bundler compatibility.\n * */\nexport class ClientDecorator {\n constructor(\n private readonly errorProcessor: ErrorProcessor,\n protected logger = scwLogger\n ) {}\n\n public decorate<Client extends SmartAccountClient<EntryPoint>>({\n crossmintChain,\n smartAccountClient,\n }: {\n crossmintChain: SmartWalletChain;\n smartAccountClient: Client;\n }): Client {\n return new Proxy(smartAccountClient, {\n get: (target, prop, receiver) => {\n const originalMethod = Reflect.get(target, prop, receiver);\n\n if (\n typeof originalMethod !== \"function\" ||\n typeof prop !== \"string\" ||\n !(isSignMethod(prop) || isTxnMethod(prop))\n ) {\n return originalMethod;\n }\n\n return (...args: any[]) =>\n this.logger.logPerformance(`CrossmintSmartWallet.${prop}`, () =>\n this.execute(target, prop, originalMethod, args, crossmintChain)\n );\n },\n }) as Client;\n }\n\n private async execute<M extends TxnMethod | SignMethod>(\n target: SmartAccountClient<EntryPoint>,\n prop: M,\n originalMethod: Function,\n args: any[],\n crossmintChain: SmartWalletChain\n ) {\n try {\n this.logger.log(`[CrossmintSmartWallet.${prop}] - params: ${stringify(args)}`);\n const processed = isTxnMethod(prop) ? this.processTxnArgs(prop, crossmintChain, args) : args;\n return await originalMethod.call(target, ...processed);\n } catch (error: any) {\n const description = isTxnMethod(prop) ? \"signing\" : \"sending transaction\";\n throw this.errorProcessor.map(\n error,\n new SmartWalletError(`Error ${description}: ${error.message}`, stringify(error))\n );\n }\n }\n\n private processTxnArgs(prop: TxnMethod, crossmintChain: SmartWalletChain, args: any[]): any[] {\n if (prop === \"sendUserOperation\") {\n const [{ userOperation, middleware, account }] = args as Parameters<\n SmartAccountClient<EntryPoint>[\"sendUserOperation\"]\n >;\n return [\n {\n middleware,\n account,\n userOperation: this.addGelatoBundlerProperties(crossmintChain, userOperation),\n },\n ...args.slice(1),\n ];\n }\n\n const [txn] = args as\n | Parameters<SmartAccountClient<EntryPoint>[\"sendTransaction\"]>\n | Parameters<SmartAccountClient<EntryPoint>[\"writeContract\"]>;\n\n return [this.addGelatoBundlerProperties(crossmintChain, txn), ...args.slice(1)];\n }\n\n /*\n * Chain that ZD uses Gelato as for bundler require special parameters:\n * https://docs.zerodev.app/sdk/faqs/use-with-gelato#transaction-configuration\n */\n private addGelatoBundlerProperties(\n crossmintChain: SmartWalletChain,\n txnParams: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }\n ) {\n if (usesGelatoBundler(crossmintChain)) {\n return { ...txnParams, maxFeePerGas: \"0x0\" as any, maxPriorityFeePerGas: \"0x0\" as any };\n }\n\n return txnParams;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-KHROQTVY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,14 @@
1
+ import {
2
+ SCW_SERVICE
3
+ } from "./chunk-UDDYHPSW.js";
4
+
5
+ // src/services/logger.ts
6
+ import { SDKLogger, getBrowserLogger } from "@crossmint/client-sdk-base";
7
+ var scwLogger = new SDKLogger(SCW_SERVICE);
8
+ var scwDatadogLogger = new SDKLogger(SCW_SERVICE, getBrowserLogger(SCW_SERVICE, { onlyDatadog: true }));
9
+
10
+ export {
11
+ scwLogger,
12
+ scwDatadogLogger
13
+ };
14
+ //# sourceMappingURL=chunk-MAID7XYG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/logger.ts"],"sourcesContent":["import { SDKLogger, getBrowserLogger } from \"@crossmint/client-sdk-base\";\n\nimport { SCW_SERVICE } from \"../utils/constants\";\n\nexport const scwLogger = new SDKLogger(SCW_SERVICE);\nexport const scwDatadogLogger = new SDKLogger(SCW_SERVICE, getBrowserLogger(SCW_SERVICE, { onlyDatadog: true }));\n"],"mappings":";;;;;AAAA,SAAS,WAAW,wBAAwB;AAIrC,IAAM,YAAY,IAAI,UAAU,WAAW;AAC3C,IAAM,mBAAmB,IAAI,UAAU,aAAa,iBAAiB,aAAa,EAAE,aAAa,KAAK,CAAC,CAAC;","names":[]}
@@ -0,0 +1,123 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkN6DG5EZGcjs = require('./chunk-N6DG5EZG.cjs');
4
+
5
+
6
+ var _chunkKEY2LM72cjs = require('./chunk-KEY2LM72.cjs');
7
+
8
+
9
+ var _chunkRB4JSPZHcjs = require('./chunk-RB4JSPZH.cjs');
10
+
11
+
12
+ var _chunkIDNF4BNPcjs = require('./chunk-IDNF4BNP.cjs');
13
+
14
+
15
+ var _chunk77GT6B5Lcjs = require('./chunk-77GT6B5L.cjs');
16
+
17
+
18
+ var _chunkOCG67QSUcjs = require('./chunk-OCG67QSU.cjs');
19
+
20
+
21
+ var _chunkDTEA33DFcjs = require('./chunk-DTEA33DF.cjs');
22
+
23
+
24
+ var _chunkEPEGJY6Ncjs = require('./chunk-EPEGJY6N.cjs');
25
+
26
+
27
+ var _chunkEUQLY4SCcjs = require('./chunk-EUQLY4SC.cjs');
28
+
29
+
30
+
31
+ var _chunkC5ZRYSCPcjs = require('./chunk-C5ZRYSCP.cjs');
32
+
33
+
34
+
35
+ var _chunkPVFA6PBXcjs = require('./chunk-PVFA6PBX.cjs');
36
+
37
+
38
+ var _chunkTK3ZLI22cjs = require('./chunk-TK3ZLI22.cjs');
39
+
40
+
41
+ var _chunkTUVECZA7cjs = require('./chunk-TUVECZA7.cjs');
42
+
43
+
44
+ var _chunkBXSAJOIVcjs = require('./chunk-BXSAJOIV.cjs');
45
+
46
+ // src/SmartWalletSDK.ts
47
+ var _viem = require('viem');
48
+ var _commonsdkbase = require('@crossmint/common-sdk-base');
49
+ var SmartWalletSDK = class _SmartWalletSDK {
50
+ constructor(crossmintEnv, smartWalletService, errorProcessor, logger = _chunkC5ZRYSCPcjs.scwLogger) {
51
+ this.crossmintEnv = crossmintEnv;
52
+ this.smartWalletService = smartWalletService;
53
+ this.errorProcessor = errorProcessor;
54
+ this.logger = logger;
55
+ }
56
+ /**
57
+ * Initializes the SDK with the **client side** API key obtained from the Crossmint console.
58
+ * @throws error if the api key is not formatted correctly.
59
+ */
60
+ static init({ clientApiKey }) {
61
+ const validationResult = _commonsdkbase.validateAPIKey.call(void 0, clientApiKey);
62
+ if (!validationResult.isValid) {
63
+ throw new Error("API key invalid");
64
+ }
65
+ const crossmintService = new (0, _chunkEUQLY4SCcjs.CrossmintWalletService)(clientApiKey);
66
+ const errorProcessor = new (0, _chunkTK3ZLI22cjs.ErrorProcessor)(_chunkC5ZRYSCPcjs.scwDatadogLogger);
67
+ const accountCreator = new (0, _chunkOCG67QSUcjs.AccountCreator)(
68
+ new (0, _chunkDTEA33DFcjs.EOACreationStrategy)(),
69
+ new (0, _chunkN6DG5EZGcjs.PasskeyCreationStrategy)(crossmintService.getPasskeyServerUrl(), clientApiKey)
70
+ );
71
+ const accountCache = new (0, _chunkIDNF4BNPcjs.AccountConfigCache)(`smart-wallet-${_chunkTUVECZA7cjs.SDK_VERSION}`);
72
+ const smartWalletService = new (0, _chunkRB4JSPZHcjs.SmartWalletService)(
73
+ crossmintService,
74
+ new (0, _chunk77GT6B5Lcjs.AccountConfigService)(crossmintService, accountCache),
75
+ accountCreator,
76
+ new (0, _chunkKEY2LM72cjs.ClientDecorator)(errorProcessor)
77
+ );
78
+ return new _SmartWalletSDK(validationResult.environment, smartWalletService, errorProcessor);
79
+ }
80
+ /**
81
+ * Retrieves or creates a wallet for the specified user.
82
+ * The default configuration is a `PasskeySigner` with the name, which is displayed to the user during creation or signing prompts, derived from the provided jwt.
83
+ *
84
+ * Example using the default passkey signer:
85
+ * ```ts
86
+ * const wallet = await smartWalletSDK.getOrCreateWallet({ jwt: "xxx" }, "base");
87
+ * ```
88
+ */
89
+ async getOrCreateWallet(user, chain, walletParams = { signer: { type: "PASSKEY" } }) {
90
+ if (!_chunkEPEGJY6Ncjs.isClient.call(void 0, )) {
91
+ throw new (0, _chunkBXSAJOIVcjs.SmartWalletError)("Smart Wallet SDK should only be used client side.");
92
+ }
93
+ this.assertValidChain(chain);
94
+ return await this.logger.logPerformance("GET_OR_CREATE_WALLET", async () => {
95
+ try {
96
+ return await this.smartWalletService.getOrCreate(user, chain, walletParams);
97
+ } catch (error) {
98
+ throw this.errorProcessor.map(
99
+ error,
100
+ new (0, _chunkBXSAJOIVcjs.SmartWalletError)(`Wallet creation failed: ${error.message}.`, _viem.stringify.call(void 0, error))
101
+ );
102
+ }
103
+ });
104
+ }
105
+ assertValidChain(chain) {
106
+ if (!this.validChain(chain)) {
107
+ throw new (0, _chunkBXSAJOIVcjs.SmartWalletError)(
108
+ `The selected chain "${chain}" is not available in "${this.crossmintEnv}". Either set a valid chain or check you're using an API key for the environment you're trying to target.`
109
+ );
110
+ }
111
+ }
112
+ validChain(chain) {
113
+ if (this.crossmintEnv === "development" || this.crossmintEnv === "staging") {
114
+ return _chunkPVFA6PBXcjs.isTestnetChain.call(void 0, chain);
115
+ }
116
+ return _chunkPVFA6PBXcjs.isMainnetChain.call(void 0, chain);
117
+ }
118
+ };
119
+
120
+
121
+
122
+ exports.SmartWalletSDK = SmartWalletSDK;
123
+ //# sourceMappingURL=chunk-MJZ2DXMN.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/SmartWalletSDK.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAAiB;AAE1B,SAAuC,sBAAsB;AAmBtD,IAAM,iBAAN,MAAM,gBAAe;AAAA,EAChB,YACa,cACA,oBACA,gBACA,SAAS,WAC5B;AAJmB;AACA;AACA;AACA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMH,OAAO,KAAK,EAAE,aAAa,GAA6C;AACpE,UAAM,mBAAmB,eAAe,YAAY;AACpD,QAAI,CAAC,iBAAiB,SAAS;AAC3B,YAAM,IAAI,MAAM,iBAAiB;AAAA,IACrC;AAEA,UAAM,mBAAmB,IAAI,uBAAuB,YAAY;AAChE,UAAM,iBAAiB,IAAI,eAAe,gBAAgB;AAC1D,UAAM,iBAAiB,IAAI;AAAA,MACvB,IAAI,oBAAoB;AAAA,MACxB,IAAI,wBAAwB,iBAAiB,oBAAoB,GAAG,YAAY;AAAA,IACpF;AACA,UAAM,eAAe,IAAI,mBAAmB,gBAAgB,WAAW,EAAE;AAEzE,UAAM,qBAAqB,IAAI;AAAA,MAC3B;AAAA,MACA,IAAI,qBAAqB,kBAAkB,YAAY;AAAA,MACvD;AAAA,MACA,IAAI,gBAAgB,cAAc;AAAA,IACtC;AAEA,WAAO,IAAI,gBAAe,iBAAiB,aAAa,oBAAoB,cAAc;AAAA,EAC9F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,kBACF,MACA,OACA,eAA6B,EAAE,QAAQ,EAAE,MAAM,UAAU,EAAE,GACpC;AACvB,QAAI,CAAC,SAAS,GAAG;AACb,YAAM,IAAI,iBAAiB,mDAAmD;AAAA,IAClF;AACA,SAAK,iBAAiB,KAAK;AAE3B,WAAO,MAAM,KAAK,OAAO,eAAe,wBAAwB,YAAY;AACxE,UAAI;AACA,eAAO,MAAM,KAAK,mBAAmB,YAAY,MAAM,OAAO,YAAY;AAAA,MAC9E,SAAS,OAAY;AACjB,cAAM,KAAK,eAAe;AAAA,UACtB;AAAA,UACA,IAAI,iBAAiB,2BAA2B,MAAM,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,QACtF;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEQ,iBAAiB,OAAyB;AAC9C,QAAI,CAAC,KAAK,WAAW,KAAK,GAAG;AACzB,YAAM,IAAI;AAAA,QACN,uBAAuB,KAAK,0BAA0B,KAAK,YAAY;AAAA,MAC3E;AAAA,IACJ;AAAA,EACJ;AAAA,EAEQ,WAAW,OAAkC;AACjD,QAAI,KAAK,iBAAiB,iBAAiB,KAAK,iBAAiB,WAAW;AACxE,aAAO,eAAe,KAAK;AAAA,IAC/B;AAEA,WAAO,eAAe,KAAK;AAAA,EAC/B;AACJ","sourcesContent":["import { stringify } from \"viem\";\n\nimport { type APIKeyEnvironmentPrefix, validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintWalletService } from \"./api/CrossmintWalletService\";\nimport { type SmartWalletChain, isMainnetChain, isTestnetChain } from \"./blockchain/chains\";\nimport type { EVMSmartWallet } from \"./blockchain/wallets\";\nimport { AccountConfigCache } from \"./blockchain/wallets/account/cache\";\nimport { AccountConfigService } from \"./blockchain/wallets/account/config\";\nimport { AccountCreator } from \"./blockchain/wallets/account/creator\";\nimport { EOACreationStrategy } from \"./blockchain/wallets/account/eoa\";\nimport { PasskeyCreationStrategy } from \"./blockchain/wallets/account/passkey\";\nimport { ClientDecorator } from \"./blockchain/wallets/clientDecorator\";\nimport { SmartWalletService } from \"./blockchain/wallets/service\";\nimport { SmartWalletError } from \"./error\";\nimport { ErrorProcessor } from \"./error/processor\";\nimport { scwDatadogLogger, scwLogger } from \"./services\";\nimport type { SmartWalletSDKInitParams, UserParams, WalletParams } from \"./types/params\";\nimport { SDK_VERSION } from \"./utils/constants\";\nimport { isClient } from \"./utils/environment\";\n\nexport class SmartWalletSDK {\n private constructor(\n private readonly crossmintEnv: APIKeyEnvironmentPrefix,\n private readonly smartWalletService: SmartWalletService,\n private readonly errorProcessor: ErrorProcessor,\n private readonly logger = scwLogger\n ) {}\n\n /**\n * Initializes the SDK with the **client side** API key obtained from the Crossmint console.\n * @throws error if the api key is not formatted correctly.\n */\n static init({ clientApiKey }: SmartWalletSDKInitParams): SmartWalletSDK {\n const validationResult = validateAPIKey(clientApiKey);\n if (!validationResult.isValid) {\n throw new Error(\"API key invalid\");\n }\n\n const crossmintService = new CrossmintWalletService(clientApiKey);\n const errorProcessor = new ErrorProcessor(scwDatadogLogger);\n const accountCreator = new AccountCreator(\n new EOACreationStrategy(),\n new PasskeyCreationStrategy(crossmintService.getPasskeyServerUrl(), clientApiKey)\n );\n const accountCache = new AccountConfigCache(`smart-wallet-${SDK_VERSION}`);\n\n const smartWalletService = new SmartWalletService(\n crossmintService,\n new AccountConfigService(crossmintService, accountCache),\n accountCreator,\n new ClientDecorator(errorProcessor)\n );\n\n return new SmartWalletSDK(validationResult.environment, smartWalletService, errorProcessor);\n }\n\n /**\n * Retrieves or creates a wallet for the specified user.\n * The default configuration is a `PasskeySigner` with the name, which is displayed to the user during creation or signing prompts, derived from the provided jwt.\n *\n * Example using the default passkey signer:\n * ```ts\n * const wallet = await smartWalletSDK.getOrCreateWallet({ jwt: \"xxx\" }, \"base\");\n * ```\n */\n async getOrCreateWallet(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams = { signer: { type: \"PASSKEY\" } }\n ): Promise<EVMSmartWallet> {\n if (!isClient()) {\n throw new SmartWalletError(\"Smart Wallet SDK should only be used client side.\");\n }\n this.assertValidChain(chain);\n\n return await this.logger.logPerformance(\"GET_OR_CREATE_WALLET\", async () => {\n try {\n return await this.smartWalletService.getOrCreate(user, chain, walletParams);\n } catch (error: any) {\n throw this.errorProcessor.map(\n error,\n new SmartWalletError(`Wallet creation failed: ${error.message}.`, stringify(error))\n );\n }\n });\n }\n\n private assertValidChain(chain: SmartWalletChain) {\n if (!this.validChain(chain)) {\n throw new SmartWalletError(\n `The selected chain \"${chain}\" is not available in \"${this.crossmintEnv}\". Either set a valid chain or check you're using an API key for the environment you're trying to target.`\n );\n }\n }\n\n private validChain(chain: SmartWalletChain): boolean {\n if (this.crossmintEnv === \"development\" || this.crossmintEnv === \"staging\") {\n return isTestnetChain(chain);\n }\n\n return isMainnetChain(chain);\n }\n}\n"]}