@crossmint/client-sdk-smart-wallet 0.1.24 → 0.1.26

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 (351) hide show
  1. package/dist/SmartWalletSDK.cjs +1 -34
  2. package/dist/SmartWalletSDK.js +1 -34
  3. package/dist/api/CrossmintWalletService.cjs +1 -13
  4. package/dist/api/CrossmintWalletService.js +1 -13
  5. package/dist/blockchain/chains.cjs +1 -23
  6. package/dist/blockchain/chains.js +1 -23
  7. package/dist/blockchain/rpc.cjs +1 -11
  8. package/dist/blockchain/rpc.js +1 -11
  9. package/dist/blockchain/transfer.cjs +1 -7
  10. package/dist/blockchain/transfer.js +1 -7
  11. package/dist/blockchain/wallets/EVMSmartWallet.cjs +1 -10
  12. package/dist/blockchain/wallets/EVMSmartWallet.js +1 -10
  13. package/dist/blockchain/wallets/SendTransactionService.cjs +1 -11
  14. package/dist/blockchain/wallets/SendTransactionService.js +1 -11
  15. package/dist/blockchain/wallets/account/cache.cjs +1 -9
  16. package/dist/blockchain/wallets/account/cache.js +1 -9
  17. package/dist/blockchain/wallets/account/config.cjs +1 -9
  18. package/dist/blockchain/wallets/account/config.js +1 -9
  19. package/dist/blockchain/wallets/account/creator.cjs +1 -10
  20. package/dist/blockchain/wallets/account/creator.js +1 -10
  21. package/dist/blockchain/wallets/account/eoa.cjs +1 -11
  22. package/dist/blockchain/wallets/account/eoa.js +1 -11
  23. package/dist/blockchain/wallets/account/passkey.cjs +1 -9
  24. package/dist/blockchain/wallets/account/passkey.js +1 -9
  25. package/dist/blockchain/wallets/account/signer.cjs +1 -9
  26. package/dist/blockchain/wallets/account/signer.js +1 -9
  27. package/dist/blockchain/wallets/account/strategy.cjs +1 -1
  28. package/dist/blockchain/wallets/account/strategy.js +0 -1
  29. package/dist/blockchain/wallets/clientDecorator.cjs +1 -12
  30. package/dist/blockchain/wallets/clientDecorator.js +1 -12
  31. package/dist/blockchain/wallets/index.cjs +1 -10
  32. package/dist/blockchain/wallets/index.js +1 -10
  33. package/dist/blockchain/wallets/paymaster.cjs +1 -10
  34. package/dist/blockchain/wallets/paymaster.js +1 -10
  35. package/dist/blockchain/wallets/service.cjs +1 -16
  36. package/dist/blockchain/wallets/service.js +1 -16
  37. package/dist/chunk-265KNPZR.js +1 -0
  38. package/dist/chunk-2GS5TXEY.cjs +1 -0
  39. package/dist/chunk-2R6HK64N.cjs +1 -0
  40. package/dist/chunk-3F6P4HUZ.js +1 -0
  41. package/dist/chunk-4SPA557P.js +0 -0
  42. package/dist/chunk-7AVDZZGD.cjs +1 -0
  43. package/dist/chunk-7FXFOOQU.cjs +1 -0
  44. package/dist/chunk-7KTCGFU5.js +1 -0
  45. package/dist/chunk-AK6IIUTM.js +1 -0
  46. package/dist/chunk-ATQ4WGCW.js +1 -0
  47. package/dist/chunk-BIJAOWPS.js +1 -0
  48. package/dist/chunk-BJZQA5VC.js +1 -0
  49. package/dist/chunk-C3VZY7VJ.js +1 -0
  50. package/dist/chunk-CUTQYF3F.js +1 -0
  51. package/dist/chunk-D4NDUT36.js +1 -0
  52. package/dist/chunk-DIDKPOO2.cjs +1 -0
  53. package/dist/chunk-DQNKQDE2.cjs +1 -0
  54. package/dist/chunk-E3NG3YWO.js +1 -0
  55. package/dist/chunk-ETVJGLNY.js +1 -0
  56. package/dist/chunk-FHNNZVNU.js +1 -0
  57. package/dist/chunk-GB35YMN4.cjs +1 -0
  58. package/dist/chunk-H4CMXNVK.js +1 -0
  59. package/dist/chunk-HGA3WK6L.cjs +1 -0
  60. package/dist/chunk-II4HKF7X.cjs +1 -0
  61. package/dist/chunk-IQTGPM2U.cjs +1 -0
  62. package/dist/chunk-KYPTGHC6.cjs +1 -0
  63. package/dist/chunk-LDNU6SJL.cjs +3 -0
  64. package/dist/chunk-M4K3IZTT.cjs +1 -0
  65. package/dist/chunk-MJ62KCTK.cjs +1 -0
  66. package/dist/chunk-NAX6LRUY.cjs +1 -0
  67. package/dist/chunk-NLGILHJS.js +1 -0
  68. package/dist/chunk-O2ACORII.cjs +1 -0
  69. package/dist/chunk-ODAUWGUU.cjs +1 -0
  70. package/dist/chunk-PZ6Q22YJ.js +1 -0
  71. package/dist/chunk-QD2JKGX6.cjs +1 -0
  72. package/dist/chunk-S2XBSAGM.js +1 -0
  73. package/dist/chunk-SBW2PS63.cjs +1 -0
  74. package/dist/chunk-SCXFZMLR.cjs +1 -0
  75. package/dist/chunk-STH2LE35.cjs +1 -0
  76. package/dist/chunk-SWWOVT47.cjs +1 -0
  77. package/dist/chunk-TBTRV56U.cjs +2 -0
  78. package/dist/chunk-TWADESPF.cjs +1 -0
  79. package/dist/chunk-TXLAUKCK.cjs +1 -0
  80. package/dist/chunk-TZG6MROQ.js +1 -0
  81. package/dist/chunk-UG47CBKR.js +1 -0
  82. package/dist/chunk-UPURFW46.js +1 -0
  83. package/dist/chunk-UXNWF66Q.js +1 -0
  84. package/dist/chunk-VMOQWOZV.js +3 -0
  85. package/dist/chunk-VXGNAQOW.js +1 -0
  86. package/dist/chunk-WJ6XJMRD.cjs +1 -0
  87. package/dist/{chunk-5MG5CIEX.cjs → chunk-XJGFG3RT.cjs} +1 -13
  88. package/dist/chunk-XQ2K2K23.cjs +1 -0
  89. package/dist/chunk-YBHSEZMB.js +1 -0
  90. package/dist/chunk-YJUD5MVS.js +1 -0
  91. package/dist/chunk-YUWCRSYD.js +1 -0
  92. package/dist/chunk-Z7MMOBIC.js +2 -0
  93. package/dist/error/index.cjs +1 -25
  94. package/dist/error/index.js +1 -25
  95. package/dist/error/processor.cjs +1 -9
  96. package/dist/error/processor.js +1 -9
  97. package/dist/index.cjs +1 -86
  98. package/dist/index.js +1 -86
  99. package/dist/services/index.cjs +1 -11
  100. package/dist/services/index.js +1 -11
  101. package/dist/services/logger.cjs +1 -10
  102. package/dist/services/logger.js +1 -10
  103. package/dist/types/internal.cjs +1 -18
  104. package/dist/types/internal.js +1 -18
  105. package/dist/types/params.cjs +1 -1
  106. package/dist/types/params.js +0 -1
  107. package/dist/types/schema.cjs +1 -16
  108. package/dist/types/schema.js +1 -16
  109. package/dist/types/service.cjs +1 -1
  110. package/dist/types/service.js +0 -1
  111. package/dist/types/token.cjs +1 -1
  112. package/dist/types/token.js +0 -1
  113. package/dist/utils/api.cjs +1 -9
  114. package/dist/utils/api.js +1 -9
  115. package/dist/utils/blockchain.cjs +1 -7
  116. package/dist/utils/blockchain.js +1 -7
  117. package/dist/utils/constants.cjs +1 -19
  118. package/dist/utils/constants.js +1 -19
  119. package/dist/utils/environment.cjs +1 -7
  120. package/dist/utils/environment.js +1 -7
  121. package/dist/utils/helpers.cjs +1 -9
  122. package/dist/utils/helpers.js +1 -9
  123. package/dist/utils/signer.cjs +1 -10
  124. package/dist/utils/signer.js +1 -10
  125. package/dist/utils/test.cjs +1 -27
  126. package/dist/utils/test.js +1 -27
  127. package/package.json +3 -4
  128. package/dist/SmartWalletSDK.cjs.map +0 -1
  129. package/dist/SmartWalletSDK.js.map +0 -1
  130. package/dist/api/CrossmintWalletService.cjs.map +0 -1
  131. package/dist/api/CrossmintWalletService.js.map +0 -1
  132. package/dist/blockchain/chains.cjs.map +0 -1
  133. package/dist/blockchain/chains.js.map +0 -1
  134. package/dist/blockchain/rpc.cjs.map +0 -1
  135. package/dist/blockchain/rpc.js.map +0 -1
  136. package/dist/blockchain/transfer.cjs.map +0 -1
  137. package/dist/blockchain/transfer.js.map +0 -1
  138. package/dist/blockchain/wallets/EVMSmartWallet.cjs.map +0 -1
  139. package/dist/blockchain/wallets/EVMSmartWallet.js.map +0 -1
  140. package/dist/blockchain/wallets/SendTransactionService.cjs.map +0 -1
  141. package/dist/blockchain/wallets/SendTransactionService.js.map +0 -1
  142. package/dist/blockchain/wallets/account/cache.cjs.map +0 -1
  143. package/dist/blockchain/wallets/account/cache.js.map +0 -1
  144. package/dist/blockchain/wallets/account/config.cjs.map +0 -1
  145. package/dist/blockchain/wallets/account/config.js.map +0 -1
  146. package/dist/blockchain/wallets/account/creator.cjs.map +0 -1
  147. package/dist/blockchain/wallets/account/creator.js.map +0 -1
  148. package/dist/blockchain/wallets/account/eoa.cjs.map +0 -1
  149. package/dist/blockchain/wallets/account/eoa.js.map +0 -1
  150. package/dist/blockchain/wallets/account/passkey.cjs.map +0 -1
  151. package/dist/blockchain/wallets/account/passkey.js.map +0 -1
  152. package/dist/blockchain/wallets/account/signer.cjs.map +0 -1
  153. package/dist/blockchain/wallets/account/signer.js.map +0 -1
  154. package/dist/blockchain/wallets/account/strategy.cjs.map +0 -1
  155. package/dist/blockchain/wallets/account/strategy.js.map +0 -1
  156. package/dist/blockchain/wallets/clientDecorator.cjs.map +0 -1
  157. package/dist/blockchain/wallets/clientDecorator.js.map +0 -1
  158. package/dist/blockchain/wallets/index.cjs.map +0 -1
  159. package/dist/blockchain/wallets/index.js.map +0 -1
  160. package/dist/blockchain/wallets/paymaster.cjs.map +0 -1
  161. package/dist/blockchain/wallets/paymaster.js.map +0 -1
  162. package/dist/blockchain/wallets/service.cjs.map +0 -1
  163. package/dist/blockchain/wallets/service.js.map +0 -1
  164. package/dist/chunk-2BBSPDW4.cjs +0 -99
  165. package/dist/chunk-2BBSPDW4.cjs.map +0 -1
  166. package/dist/chunk-2GADBKIW.cjs +0 -39
  167. package/dist/chunk-2GADBKIW.cjs.map +0 -1
  168. package/dist/chunk-2HB65Y7D.js +0 -79
  169. package/dist/chunk-2HB65Y7D.js.map +0 -1
  170. package/dist/chunk-3EQHAQXO.js +0 -112
  171. package/dist/chunk-3EQHAQXO.js.map +0 -1
  172. package/dist/chunk-3R6PW6HY.js +0 -30
  173. package/dist/chunk-3R6PW6HY.js.map +0 -1
  174. package/dist/chunk-5MG5CIEX.cjs.map +0 -1
  175. package/dist/chunk-5URMCCO6.js +0 -9
  176. package/dist/chunk-5URMCCO6.js.map +0 -1
  177. package/dist/chunk-5WVQ7J3E.cjs +0 -369
  178. package/dist/chunk-5WVQ7J3E.cjs.map +0 -1
  179. package/dist/chunk-6FS2OI5W.js +0 -66
  180. package/dist/chunk-6FS2OI5W.js.map +0 -1
  181. package/dist/chunk-6NJVFL2X.js +0 -60
  182. package/dist/chunk-6NJVFL2X.js.map +0 -1
  183. package/dist/chunk-74NTQGER.js +0 -44
  184. package/dist/chunk-74NTQGER.js.map +0 -1
  185. package/dist/chunk-77GT6B5L.cjs +0 -79
  186. package/dist/chunk-77GT6B5L.cjs.map +0 -1
  187. package/dist/chunk-7KTQNIAZ.cjs +0 -112
  188. package/dist/chunk-7KTQNIAZ.cjs.map +0 -1
  189. package/dist/chunk-7ORLXP6K.cjs +0 -93
  190. package/dist/chunk-7ORLXP6K.cjs.map +0 -1
  191. package/dist/chunk-ASIPMVRQ.js +0 -90
  192. package/dist/chunk-ASIPMVRQ.js.map +0 -1
  193. package/dist/chunk-BARW756O.js +0 -27
  194. package/dist/chunk-BARW756O.js.map +0 -1
  195. package/dist/chunk-BXSAJOIV.cjs +0 -90
  196. package/dist/chunk-BXSAJOIV.cjs.map +0 -1
  197. package/dist/chunk-DTEA33DF.cjs +0 -59
  198. package/dist/chunk-DTEA33DF.cjs.map +0 -1
  199. package/dist/chunk-DYO4HODM.cjs +0 -36
  200. package/dist/chunk-DYO4HODM.cjs.map +0 -1
  201. package/dist/chunk-EPEGJY6N.cjs +0 -9
  202. package/dist/chunk-EPEGJY6N.cjs.map +0 -1
  203. package/dist/chunk-EQSMHR77.js +0 -30
  204. package/dist/chunk-EQSMHR77.js.map +0 -1
  205. package/dist/chunk-FSIMJYXR.js +0 -36
  206. package/dist/chunk-FSIMJYXR.js.map +0 -1
  207. package/dist/chunk-FXGOVLZW.cjs +0 -9
  208. package/dist/chunk-FXGOVLZW.cjs.map +0 -1
  209. package/dist/chunk-ICLDP7BD.cjs +0 -36
  210. package/dist/chunk-ICLDP7BD.cjs.map +0 -1
  211. package/dist/chunk-IZZQHNZT.cjs +0 -22
  212. package/dist/chunk-IZZQHNZT.cjs.map +0 -1
  213. package/dist/chunk-JLZCSWUY.cjs +0 -14
  214. package/dist/chunk-JLZCSWUY.cjs.map +0 -1
  215. package/dist/chunk-JOB7STIS.js +0 -9
  216. package/dist/chunk-JOB7STIS.js.map +0 -1
  217. package/dist/chunk-KHROQTVY.js +0 -1
  218. package/dist/chunk-KHROQTVY.js.map +0 -1
  219. package/dist/chunk-LWVV7JDJ.js +0 -36
  220. package/dist/chunk-LWVV7JDJ.js.map +0 -1
  221. package/dist/chunk-N6DG5EZG.cjs +0 -156
  222. package/dist/chunk-N6DG5EZG.cjs.map +0 -1
  223. package/dist/chunk-NI6WQXMN.js +0 -99
  224. package/dist/chunk-NI6WQXMN.js.map +0 -1
  225. package/dist/chunk-O6IFYHDP.cjs +0 -36
  226. package/dist/chunk-O6IFYHDP.cjs.map +0 -1
  227. package/dist/chunk-OGA3YDWS.cjs +0 -112
  228. package/dist/chunk-OGA3YDWS.cjs.map +0 -1
  229. package/dist/chunk-OIEP34C6.js +0 -41
  230. package/dist/chunk-OIEP34C6.js.map +0 -1
  231. package/dist/chunk-ON4DOYVD.js +0 -369
  232. package/dist/chunk-ON4DOYVD.js.map +0 -1
  233. package/dist/chunk-PVFA6PBX.cjs +0 -60
  234. package/dist/chunk-PVFA6PBX.cjs.map +0 -1
  235. package/dist/chunk-QBQDYMNI.js +0 -39
  236. package/dist/chunk-QBQDYMNI.js.map +0 -1
  237. package/dist/chunk-QJ3BSVGV.js +0 -36
  238. package/dist/chunk-QJ3BSVGV.js.map +0 -1
  239. package/dist/chunk-RUTDRRS2.cjs +0 -66
  240. package/dist/chunk-RUTDRRS2.cjs.map +0 -1
  241. package/dist/chunk-SBR2CREX.js +0 -82
  242. package/dist/chunk-SBR2CREX.js.map +0 -1
  243. package/dist/chunk-SMDX2MXU.js +0 -13
  244. package/dist/chunk-SMDX2MXU.js.map +0 -1
  245. package/dist/chunk-TDJDKTRS.js +0 -156
  246. package/dist/chunk-TDJDKTRS.js.map +0 -1
  247. package/dist/chunk-TZUJ5MXW.cjs +0 -82
  248. package/dist/chunk-TZUJ5MXW.cjs.map +0 -1
  249. package/dist/chunk-U4OBHCIP.js +0 -59
  250. package/dist/chunk-U4OBHCIP.js.map +0 -1
  251. package/dist/chunk-UQKE6R5W.cjs +0 -27
  252. package/dist/chunk-UQKE6R5W.cjs.map +0 -1
  253. package/dist/chunk-UZGHOTKZ.js +0 -112
  254. package/dist/chunk-UZGHOTKZ.js.map +0 -1
  255. package/dist/chunk-WRH3YJT3.js +0 -14
  256. package/dist/chunk-WRH3YJT3.js.map +0 -1
  257. package/dist/chunk-X4KT4AKM.cjs +0 -123
  258. package/dist/chunk-X4KT4AKM.cjs.map +0 -1
  259. package/dist/chunk-YKW7PMBU.js +0 -22
  260. package/dist/chunk-YKW7PMBU.js.map +0 -1
  261. package/dist/chunk-YWCXHOSD.cjs +0 -30
  262. package/dist/chunk-YWCXHOSD.cjs.map +0 -1
  263. package/dist/chunk-Z5DNJTAW.cjs +0 -41
  264. package/dist/chunk-Z5DNJTAW.cjs.map +0 -1
  265. package/dist/chunk-Z7JWER3L.js +0 -93
  266. package/dist/chunk-Z7JWER3L.js.map +0 -1
  267. package/dist/chunk-ZAQLXUMA.cjs +0 -44
  268. package/dist/chunk-ZAQLXUMA.cjs.map +0 -1
  269. package/dist/chunk-ZEWOQEKM.js +0 -123
  270. package/dist/chunk-ZEWOQEKM.js.map +0 -1
  271. package/dist/chunk-ZN42AA2G.cjs +0 -1
  272. package/dist/chunk-ZN42AA2G.cjs.map +0 -1
  273. package/dist/chunk-ZOXKITU4.cjs +0 -30
  274. package/dist/chunk-ZOXKITU4.cjs.map +0 -1
  275. package/dist/error/index.cjs.map +0 -1
  276. package/dist/error/index.js.map +0 -1
  277. package/dist/error/processor.cjs.map +0 -1
  278. package/dist/error/processor.js.map +0 -1
  279. package/dist/index.cjs.map +0 -1
  280. package/dist/index.js.map +0 -1
  281. package/dist/services/index.cjs.map +0 -1
  282. package/dist/services/index.js.map +0 -1
  283. package/dist/services/logger.cjs.map +0 -1
  284. package/dist/services/logger.js.map +0 -1
  285. package/dist/types/internal.cjs.map +0 -1
  286. package/dist/types/internal.js.map +0 -1
  287. package/dist/types/params.cjs.map +0 -1
  288. package/dist/types/params.js.map +0 -1
  289. package/dist/types/schema.cjs.map +0 -1
  290. package/dist/types/schema.js.map +0 -1
  291. package/dist/types/service.cjs.map +0 -1
  292. package/dist/types/service.js.map +0 -1
  293. package/dist/types/token.cjs.map +0 -1
  294. package/dist/types/token.js.map +0 -1
  295. package/dist/utils/api.cjs.map +0 -1
  296. package/dist/utils/api.js.map +0 -1
  297. package/dist/utils/blockchain.cjs.map +0 -1
  298. package/dist/utils/blockchain.js.map +0 -1
  299. package/dist/utils/constants.cjs.map +0 -1
  300. package/dist/utils/constants.js.map +0 -1
  301. package/dist/utils/environment.cjs.map +0 -1
  302. package/dist/utils/environment.js.map +0 -1
  303. package/dist/utils/helpers.cjs.map +0 -1
  304. package/dist/utils/helpers.js.map +0 -1
  305. package/dist/utils/signer.cjs.map +0 -1
  306. package/dist/utils/signer.js.map +0 -1
  307. package/dist/utils/test.cjs.map +0 -1
  308. package/dist/utils/test.js.map +0 -1
  309. package/src/ABI/ERC1155.json +0 -325
  310. package/src/ABI/ERC20.json +0 -222
  311. package/src/ABI/ERC721.json +0 -320
  312. package/src/SmartWalletSDK.test.ts +0 -31
  313. package/src/SmartWalletSDK.ts +0 -104
  314. package/src/api/CrossmintWalletService.test.ts +0 -43
  315. package/src/api/CrossmintWalletService.ts +0 -84
  316. package/src/blockchain/chains.ts +0 -57
  317. package/src/blockchain/rpc.ts +0 -25
  318. package/src/blockchain/transfer.ts +0 -54
  319. package/src/blockchain/wallets/EVMSmartWallet.ts +0 -157
  320. package/src/blockchain/wallets/SendTransactionService.test.ts +0 -159
  321. package/src/blockchain/wallets/SendTransactionService.ts +0 -188
  322. package/src/blockchain/wallets/account/cache.test.ts +0 -67
  323. package/src/blockchain/wallets/account/cache.ts +0 -43
  324. package/src/blockchain/wallets/account/config.test.ts +0 -103
  325. package/src/blockchain/wallets/account/config.ts +0 -116
  326. package/src/blockchain/wallets/account/creator.ts +0 -40
  327. package/src/blockchain/wallets/account/eoa.ts +0 -51
  328. package/src/blockchain/wallets/account/passkey.ts +0 -198
  329. package/src/blockchain/wallets/account/signer.ts +0 -44
  330. package/src/blockchain/wallets/account/strategy.ts +0 -5
  331. package/src/blockchain/wallets/clientDecorator.ts +0 -128
  332. package/src/blockchain/wallets/index.ts +0 -1
  333. package/src/blockchain/wallets/paymaster.ts +0 -41
  334. package/src/blockchain/wallets/service.ts +0 -107
  335. package/src/error/index.ts +0 -100
  336. package/src/error/processor.ts +0 -36
  337. package/src/index.ts +0 -47
  338. package/src/services/index.ts +0 -1
  339. package/src/services/logger.ts +0 -6
  340. package/src/types/internal.ts +0 -76
  341. package/src/types/params.ts +0 -34
  342. package/src/types/schema.ts +0 -63
  343. package/src/types/service.ts +0 -31
  344. package/src/types/token.ts +0 -29
  345. package/src/utils/api.ts +0 -39
  346. package/src/utils/blockchain.ts +0 -5
  347. package/src/utils/constants.ts +0 -9
  348. package/src/utils/environment.ts +0 -3
  349. package/src/utils/helpers.ts +0 -7
  350. package/src/utils/signer.ts +0 -33
  351. package/src/utils/test.ts +0 -24
@@ -1,54 +0,0 @@
1
- import { type Abi, type Account, type Address, erc20Abi, erc721Abi } from "viem";
2
-
3
- import erc1155Abi from "../ABI/ERC1155.json";
4
- import type { ERC20TransferType, SFTTransferType, TransferType } from "../types/token";
5
-
6
- type TransferInputParams = {
7
- from: Account;
8
- contract: Address;
9
- to: Address;
10
- config: TransferType;
11
- };
12
-
13
- type TransferSimulationParams = {
14
- account: Account;
15
- address: Address;
16
- abi: Abi;
17
- functionName: string;
18
- args: any[];
19
- tokenId?: string;
20
- };
21
-
22
- export function transferParams({ contract, config, from, to }: TransferInputParams): TransferSimulationParams {
23
- switch (config.token.type) {
24
- case "ft": {
25
- return {
26
- account: from,
27
- address: contract,
28
- abi: erc20Abi,
29
- functionName: "transfer",
30
- args: [to, (config as ERC20TransferType).amount],
31
- };
32
- }
33
- case "sft": {
34
- return {
35
- account: from,
36
- address: contract,
37
- abi: erc1155Abi as Abi,
38
- functionName: "safeTransferFrom",
39
- args: [from.address, to, config.token.tokenId, (config as SFTTransferType).quantity, "0x00"],
40
- tokenId: config.token.tokenId,
41
- };
42
- }
43
- case "nft": {
44
- return {
45
- account: from,
46
- address: contract,
47
- abi: erc721Abi,
48
- functionName: "safeTransferFrom",
49
- args: [from.address, to, config.token.tokenId],
50
- tokenId: config.token.tokenId,
51
- };
52
- }
53
- }
54
- }
@@ -1,157 +0,0 @@
1
- import type {
2
- Abi,
3
- Address,
4
- ContractFunctionArgs,
5
- ContractFunctionName,
6
- Hex,
7
- HttpTransport,
8
- PublicClient,
9
- WriteContractParameters,
10
- } from "viem";
11
-
12
- import type { CrossmintWalletService } from "../../api/CrossmintWalletService";
13
- import { SmartWalletError } from "../../error";
14
- import type { SmartWalletClient } from "../../types/internal";
15
- import type { TransferType } from "../../types/token";
16
- import type { SmartWalletChain } from "../chains";
17
- import { transferParams } from "../transfer";
18
- import { type SendTransactionOptions, SendTransactionService } from "./SendTransactionService";
19
-
20
- /**
21
- * Smart wallet interface for EVM chains enhanced with Crossmint capabilities.
22
- * Core functionality is exposed via [viem](https://viem.sh/) clients within the `client` property of the class.
23
- */
24
- export class EVMSmartWallet {
25
- public readonly chain: SmartWalletChain;
26
-
27
- /**
28
- * [viem](https://viem.sh/) clients that provide an interface for core wallet functionality.
29
- */
30
- public readonly client: {
31
- /**
32
- * An interface to interact with the smart wallet, execute transactions, sign messages, etc.
33
- */
34
- wallet: SmartWalletClient;
35
-
36
- /**
37
- * An interface to read onchain data, fetch transactions, retrieve account balances, etc. Corresponds to public [JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/) methods.
38
- */
39
- public: PublicClient;
40
- };
41
-
42
- constructor(
43
- client: { public: PublicClient<HttpTransport>; wallet: SmartWalletClient },
44
- chain: SmartWalletChain,
45
- private readonly crossmintService: CrossmintWalletService,
46
- private readonly sendTransactionService = new SendTransactionService(client)
47
- ) {
48
- this.chain = chain;
49
- this.client = client;
50
- }
51
-
52
- /**
53
- * The address of the smart wallet.
54
- */
55
- public get address() {
56
- return this.client.wallet.account.address;
57
- }
58
-
59
- /**
60
- * Transfers tokens from the smart wallet to a specified address.
61
- * @param toAddress The recipient's address.
62
- * @param config The transfer configuration, including token details and amount.
63
- * @returns The transaction hash.
64
- * @throws {SmartWalletError} If there's a chain mismatch between this wallet and the input configuration.
65
- * @throws {SendTransactionError} If the transaction fails to send. Contains the error thrown by the viem client.
66
- * @throws {SendTransactionExecutionRevertedError} A subclass of SendTransactionError if the transaction fails due to a contract execution error.
67
- */
68
- public async transferToken(toAddress: Address, config: TransferType): Promise<string> {
69
- if (this.chain !== config.token.chain) {
70
- throw new SmartWalletError(
71
- `Chain mismatch: Expected ${config.token.chain}, but got ${this.chain}. Ensure you are interacting with the correct blockchain.`
72
- );
73
- }
74
-
75
- return this.executeContract(
76
- transferParams({
77
- contract: config.token.contractAddress,
78
- to: toAddress,
79
- from: this.client.wallet.account,
80
- config,
81
- })
82
- );
83
- }
84
-
85
- /**
86
- * @returns A list of NFTs owned by the wallet.
87
- */
88
- public async nfts() {
89
- return this.crossmintService.fetchNFTs(this.address, this.chain);
90
- }
91
-
92
- /**
93
- * Sends a contract call transaction and returns the hash of a confirmed transaction.
94
- * @param address the address of the contract to be called
95
- * @param abi the ABI of the contract - ***should be defined as a typed variable*** to enable type checking of the contract arguments, see https://viem.sh/docs/typescript#type-inference for guidance
96
- * @param functionName the name of the smart contract function to be called
97
- * @param args the arguments to be passed to the function
98
- * @returns The transaction hash.
99
- * @throws `SendTransactionError` if the transaction fails to send. Contains the error thrown by the viem client.
100
- * @throws `SendTransactionExecutionRevertedError`, a subclass of `SendTransactionError` if the transaction fails due to a contract execution error.
101
- *
102
- * **Passing a typed ABI:**
103
- * @example
104
- * const abi = [{
105
- * "inputs": [
106
- * {
107
- * "internalType": "address",
108
- * "name": "recipient",
109
- * "type": "address"
110
- * },
111
- * ],
112
- * "name": "mintNFT",
113
- * "outputs": [],
114
- * "stateMutability": "nonpayable",
115
- * "type": "function"
116
- * }] as const;
117
- *
118
- * await wallet.executeContract({
119
- * address: contractAddress,
120
- * abi,
121
- * functionName: "mintNFT",
122
- * args: [recipientAddress],
123
- * });
124
- */
125
- public async executeContract<
126
- const TAbi extends Abi | readonly unknown[],
127
- TFunctionName extends ContractFunctionName<TAbi, "nonpayable" | "payable"> = ContractFunctionName<
128
- TAbi,
129
- "nonpayable" | "payable"
130
- >,
131
- TArgs extends ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName> = ContractFunctionArgs<
132
- TAbi,
133
- "nonpayable" | "payable",
134
- TFunctionName
135
- >,
136
- >({
137
- address,
138
- abi,
139
- functionName,
140
- args,
141
- value,
142
- config,
143
- }: Omit<WriteContractParameters<TAbi, TFunctionName, TArgs>, "chain" | "account"> & {
144
- config?: Partial<SendTransactionOptions>;
145
- }): Promise<Hex> {
146
- return this.sendTransactionService.sendTransaction(
147
- {
148
- address,
149
- abi: abi as Abi,
150
- functionName,
151
- args,
152
- value,
153
- },
154
- config
155
- );
156
- }
157
- }
@@ -1,159 +0,0 @@
1
- import type { SmartAccountClient } from "permissionless";
2
- import type { SmartAccount } from "permissionless/accounts";
3
- import type { EntryPoint } from "permissionless/types";
4
- import {
5
- type Address,
6
- BaseError,
7
- type Chain,
8
- ContractFunctionRevertedError,
9
- type PublicClient,
10
- type SimulateContractReturnType,
11
- type TransactionReceipt,
12
- type Transport,
13
- zeroAddress,
14
- } from "viem";
15
- import { beforeEach, describe, expect, it, vi } from "vitest";
16
- import { mock } from "vitest-mock-extended";
17
-
18
- import {
19
- EVMSendTransactionError,
20
- EVMSendTransactionExecutionRevertedError,
21
- SendTransactionService,
22
- } from "./SendTransactionService";
23
-
24
- function makeMockError<E extends Error, F extends object>(error: E, fields?: F): E & F {
25
- const mockError = Object.create(error);
26
- Object.assign(mockError, fields);
27
- return mockError;
28
- }
29
-
30
- describe("SendTransactionService", () => {
31
- const walletAddress: Address = "0xE898BBd704CCE799e9593a9ADe2c1cA0351Ab660";
32
- const mockSmartAccount = mock<SmartAccount<EntryPoint>>({ address: walletAddress });
33
- const mockPublicClient = mock<PublicClient>();
34
- const mockAccountClient = mock<SmartAccountClient<EntryPoint, Transport, Chain, SmartAccount<EntryPoint>>>({
35
- account: mockSmartAccount,
36
- });
37
- const sendTransactionService = new SendTransactionService({ public: mockPublicClient, wallet: mockAccountClient });
38
-
39
- beforeEach(() => {
40
- vi.resetAllMocks();
41
- });
42
-
43
- it("Throws EVMSendTransactionExecutionRevertedError when a transaction simulation fails", async () => {
44
- const mockError = makeMockError(BaseError.prototype, { walk: vi.fn() });
45
- const mockRevertError = new ContractFunctionRevertedError({
46
- abi: [],
47
- functionName: "mockFunction",
48
- message: "mockMessage",
49
- });
50
- mockRevertError.reason = "mockReason";
51
- const mockRevertData = mock<ContractFunctionRevertedError["data"]>();
52
- mockRevertError.data = mockRevertData;
53
- mockError.walk.mockReturnValue(mockRevertError);
54
- mockPublicClient.simulateContract.mockRejectedValue(mockError);
55
- let rejected = false;
56
- try {
57
- await sendTransactionService.sendTransaction({
58
- address: zeroAddress,
59
- abi: [],
60
- functionName: "mockFunction",
61
- args: [],
62
- });
63
- } catch (e) {
64
- rejected = true;
65
- expect(e).toBeInstanceOf(EVMSendTransactionExecutionRevertedError);
66
- expect((e as EVMSendTransactionExecutionRevertedError).stage).toBe("simulation");
67
- expect((e as EVMSendTransactionExecutionRevertedError).reason).toBe("mockReason");
68
- expect((e as EVMSendTransactionExecutionRevertedError).data == mockRevertData).toBe(true);
69
- }
70
- expect(rejected).toBe(true);
71
- });
72
-
73
- it("Throws EVMSendTransactionExecutionRevertedError when a transaction reverts on chain", async () => {
74
- const mockReceipt = mock<TransactionReceipt>();
75
- mockReceipt.status = "reverted";
76
- mockPublicClient.waitForTransactionReceipt.mockResolvedValueOnce(mockReceipt);
77
- let rejected = false;
78
- try {
79
- await sendTransactionService.sendTransaction({
80
- address: zeroAddress,
81
- abi: [],
82
- functionName: "mockFunction",
83
- args: [],
84
- });
85
- } catch (e) {
86
- rejected = true;
87
- expect(e).toBeInstanceOf(EVMSendTransactionExecutionRevertedError);
88
- expect((e as EVMSendTransactionExecutionRevertedError).stage).toBe("execution");
89
- }
90
- expect(rejected).toBe(true);
91
- });
92
-
93
- it("Throws a confirmation error when a transaction confirmation fails", async () => {
94
- const mockError = makeMockError(BaseError.prototype);
95
- mockPublicClient.waitForTransactionReceipt.mockRejectedValue(mockError);
96
- let rejected = false;
97
- try {
98
- await sendTransactionService.sendTransaction({
99
- address: zeroAddress,
100
- abi: [],
101
- functionName: "mockFunction",
102
- args: [],
103
- });
104
- } catch (e) {
105
- rejected = true;
106
- expect(e).toBeInstanceOf(EVMSendTransactionError);
107
- expect((e as EVMSendTransactionError).stage).toBe("confirmation");
108
- }
109
- expect(rejected).toBe(true);
110
- });
111
-
112
- it("Throws EVMSendTransactionError when a transaction fails to send", async () => {
113
- const mockError = makeMockError(BaseError.prototype);
114
- mockAccountClient.writeContract.mockRejectedValue(mockError);
115
- let rejected = false;
116
- try {
117
- await sendTransactionService.sendTransaction({
118
- address: zeroAddress,
119
- abi: [],
120
- functionName: "mockFunction",
121
- args: [],
122
- });
123
- } catch (e) {
124
- rejected = true;
125
- expect(e).toBeInstanceOf(EVMSendTransactionError);
126
- expect((e as EVMSendTransactionError).stage).toBe("send");
127
- }
128
- expect(rejected).toBe(true);
129
- });
130
-
131
- it("Simulates before sending a transaction", async () => {
132
- const mockReceipt = mock<TransactionReceipt>();
133
- mockPublicClient.waitForTransactionReceipt.mockResolvedValueOnce(mockReceipt);
134
- const callOrder: string[] = [];
135
- mockPublicClient.simulateContract.mockImplementation(async () => {
136
- callOrder.push("simulateContract");
137
- return mock<SimulateContractReturnType>();
138
- });
139
- mockAccountClient.writeContract.mockImplementation(async () => {
140
- callOrder.push("sendTransaction");
141
- return "0xmockTxHash";
142
- });
143
- await expect(
144
- sendTransactionService.sendTransaction({
145
- address: zeroAddress,
146
- abi: [],
147
- functionName: "mockFunction",
148
- args: [],
149
- })
150
- ).resolves.toBeDefined();
151
- expect(callOrder).toEqual(["simulateContract", "sendTransaction"]);
152
-
153
- expect(mockPublicClient.simulateContract).toHaveBeenCalledWith(
154
- expect.objectContaining({
155
- account: walletAddress,
156
- })
157
- );
158
- });
159
- });
@@ -1,188 +0,0 @@
1
- import type { SmartAccountClient } from "permissionless";
2
- import type { EntryPoint } from "permissionless/_types/types";
3
- import type { SmartAccount } from "permissionless/accounts";
4
- import {
5
- type Abi,
6
- type Address,
7
- BaseError,
8
- type Chain,
9
- ContractFunctionRevertedError,
10
- type Hex,
11
- type PublicClient,
12
- type TransactionReceipt,
13
- type Transport,
14
- } from "viem";
15
-
16
- import { CrossmintSDKError, WalletErrorCode } from "@crossmint/client-sdk-base";
17
-
18
- export type TransactionServiceTransactionRequest = {
19
- address: Address;
20
- abi: Abi;
21
- functionName: string;
22
- args: any;
23
- value?: bigint;
24
- };
25
-
26
- export type SendTransactionFailureStage = "simulation" | "send" | "confirmation" | "execution";
27
-
28
- /**
29
- * Error thrown when a transaction fails to send.
30
- * @param viemError The error thrown by the viem client. See https://viem.sh/docs/glossary/errors.html
31
- */
32
- export class EVMSendTransactionError extends CrossmintSDKError {
33
- constructor(
34
- message: string,
35
- public readonly viemError: BaseError,
36
- public readonly stage: SendTransactionFailureStage,
37
- code = WalletErrorCode.SEND_TRANSACTION_FAILED
38
- ) {
39
- super(message, code);
40
- }
41
- }
42
-
43
- /**
44
- * Error thrown when a transaction fails due to a contract execution error.
45
- * @param viemError The error thrown by the viem client. See https://viem.sh/docs/glossary/errors.html
46
- * @param data The name and arguments of the revert error from the provided ABI
47
- * @param reason The revert error if it is a string and not an ABI error
48
- * @example
49
- * try {
50
- * await wallet.executeContract({
51
- * address: contractAddress,
52
- * abi,
53
- * functionName: "mintNFT",
54
- * args: [recipientAddress],
55
- * });
56
- * } catch (e) {
57
- * if (e instanceof SendTransactionExecutionRevertedError) {
58
- * alert(`Transaction reverted: ${e.message}`);
59
- * }
60
- * throw e;
61
- * }
62
- */
63
- export class EVMSendTransactionExecutionRevertedError extends EVMSendTransactionError {
64
- constructor(
65
- message: string,
66
- public readonly viemError: BaseError,
67
- revertError: ContractFunctionRevertedError,
68
- public readonly txId: string | undefined,
69
- public readonly stage: SendTransactionFailureStage,
70
- public readonly data = revertError.data,
71
- public readonly reason = revertError.reason
72
- ) {
73
- super(message, viemError, stage, WalletErrorCode.SEND_TRANSACTION_EXECUTION_REVERTED);
74
- }
75
- }
76
-
77
- export interface SendTransactionOptions {
78
- /**
79
- * The number of confirmations to wait for before yielding the transaction hash.
80
- */
81
- confirmations: number;
82
- /**
83
- * The timeout in milliseconds to wait for a transaction to confirm before throwing an error.
84
- */
85
- transactionConfirmationTimeout: number;
86
- }
87
-
88
- export class SendTransactionService {
89
- constructor(
90
- private readonly client: {
91
- public: PublicClient;
92
- wallet: SmartAccountClient<EntryPoint, Transport, Chain, SmartAccount<EntryPoint>>;
93
- },
94
- private readonly defaultSendTransactionOptions: SendTransactionOptions = {
95
- confirmations: 2,
96
- transactionConfirmationTimeout: 30_000,
97
- }
98
- ) {}
99
-
100
- async sendTransaction(
101
- request: TransactionServiceTransactionRequest,
102
- config: Partial<SendTransactionOptions> = {}
103
- ): Promise<Hex> {
104
- const { confirmations, transactionConfirmationTimeout } = this.getConfig(config);
105
-
106
- await this.simulateCall(request, undefined, "simulation");
107
-
108
- let hash;
109
- try {
110
- hash = await this.client.wallet.writeContract({
111
- ...request,
112
- account: this.client.wallet.account,
113
- chain: this.client.wallet.chain,
114
- });
115
- } catch (e) {
116
- if (e instanceof BaseError) {
117
- throw new EVMSendTransactionError(e.message, e, "send");
118
- }
119
- throw e;
120
- }
121
-
122
- try {
123
- const receipt = await this.client.public.waitForTransactionReceipt({
124
- hash,
125
- confirmations,
126
- timeout: transactionConfirmationTimeout,
127
- });
128
- return await this.handleReceipt(receipt, request);
129
- } catch (e) {
130
- if (e instanceof BaseError) {
131
- throw new EVMSendTransactionError(e.message, e, "confirmation");
132
- }
133
- throw e;
134
- }
135
- }
136
-
137
- private getConfig(config: Partial<SendTransactionOptions>): SendTransactionOptions {
138
- return {
139
- ...this.defaultSendTransactionOptions,
140
- ...config,
141
- };
142
- }
143
-
144
- private async handleReceipt(receipt: TransactionReceipt, request: TransactionServiceTransactionRequest) {
145
- if (receipt.status === "reverted") {
146
- // This should revert and throw the full reason
147
- await this.simulateCall(request, receipt.transactionHash, "execution");
148
- // Otherwise, throw a generic error (this should practically never happen)
149
- throw new EVMSendTransactionExecutionRevertedError(
150
- "Transaction reverted but unable to detect the reason",
151
- new ContractFunctionRevertedError({ abi: request.abi as Abi, functionName: request.functionName }),
152
- new ContractFunctionRevertedError({ abi: request.abi as Abi, functionName: request.functionName }),
153
- receipt.transactionHash,
154
- "execution"
155
- );
156
- }
157
- return receipt.transactionHash;
158
- }
159
-
160
- private async simulateCall(
161
- request: TransactionServiceTransactionRequest,
162
- passthroughTxId: string | undefined,
163
- stage: SendTransactionFailureStage
164
- ) {
165
- try {
166
- await this.client.public.simulateContract({
167
- ...request,
168
- account: this.client.wallet.account.address,
169
- chain: this.client.public.chain,
170
- });
171
- } catch (e) {
172
- if (e instanceof BaseError) {
173
- const revertError = e.walk((err) => err instanceof ContractFunctionRevertedError);
174
- if (revertError instanceof ContractFunctionRevertedError) {
175
- throw new EVMSendTransactionExecutionRevertedError(
176
- revertError.message,
177
- e,
178
- revertError,
179
- passthroughTxId,
180
- stage
181
- );
182
- }
183
- throw new EVMSendTransactionError(e.message, e, stage);
184
- }
185
- throw e;
186
- }
187
- }
188
- }
@@ -1,67 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
-
3
- import type { UserParams } from "../../../types/params";
4
- import { mockConfig } from "../../../utils/test";
5
- import { AccountConfigCache } from "./cache";
6
-
7
- // At the top of the file, after the imports
8
- const mockLocalStorage = {
9
- getItem: vi.fn(),
10
- setItem: vi.fn(),
11
- removeItem: vi.fn(),
12
- clear: vi.fn(),
13
- length: 0,
14
- key: vi.fn(),
15
- };
16
-
17
- vi.stubGlobal("localStorage", mockLocalStorage);
18
-
19
- vi.mock("@/services/logging");
20
- vi.mock("viem", () => ({
21
- keccak256: vi.fn((input) => `mocked_keccak256_${input}`),
22
- toHex: vi.fn((input) => `mocked_hex_${input}`),
23
- isAddress: vi.fn(() => true),
24
- isHex: vi.fn(() => true),
25
- }));
26
-
27
- describe("AccountConfigCache", () => {
28
- let cache: AccountConfigCache;
29
- const mockUser: UserParams = { jwt: "test_jwt" };
30
- const cachePrefix = `smart-wallet-0.1.0`;
31
-
32
- beforeEach(() => {
33
- cache = new AccountConfigCache(cachePrefix);
34
- vi.clearAllMocks();
35
- });
36
-
37
- describe("get", () => {
38
- it("should return null if item is not in storage", () => {
39
- mockLocalStorage.getItem.mockReturnValue(null);
40
- const result = cache.get(mockUser);
41
- expect(result).toBeNull();
42
- });
43
-
44
- it("should return parsed config if valid", () => {
45
- mockLocalStorage.getItem.mockReturnValue(JSON.stringify(mockConfig));
46
- const result = cache.get(mockUser);
47
- expect(result).toEqual(mockConfig);
48
- });
49
-
50
- it("should return null and remove item if config is invalid", () => {
51
- mockLocalStorage.getItem.mockReturnValue('{"invalidKey": "invalidValue"}');
52
- const result = cache.get(mockUser);
53
- expect(result).toBeNull();
54
- expect(mockLocalStorage.removeItem).toHaveBeenCalled();
55
- });
56
- });
57
-
58
- describe("set", () => {
59
- it("should store the config in localStorage", () => {
60
- cache.set(mockUser, mockConfig);
61
- expect(mockLocalStorage.setItem).toHaveBeenCalledWith(
62
- expect.stringContaining(cachePrefix),
63
- JSON.stringify(mockConfig)
64
- );
65
- });
66
- });
67
- });
@@ -1,43 +0,0 @@
1
- import { keccak256, toHex } from "viem";
2
-
3
- import type { UserParams } from "../../../types/params";
4
- import { SmartWalletConfigSchema } from "../../../types/schema";
5
- import type { SmartWalletConfig } from "../../../types/service";
6
-
7
- export class AccountConfigCache {
8
- constructor(private readonly keyPrefix: string) {}
9
-
10
- public set(user: UserParams, config: SmartWalletConfig) {
11
- localStorage.setItem(this.key(user), JSON.stringify(config));
12
- }
13
-
14
- public get(user: UserParams): SmartWalletConfig | null {
15
- const key = this.key(user);
16
- const data = localStorage.getItem(key);
17
- if (data == null) {
18
- return null;
19
- }
20
-
21
- const result = SmartWalletConfigSchema.safeParse(JSON.parse(data));
22
- if (!result.success) {
23
- localStorage.removeItem(key);
24
- return null;
25
- }
26
-
27
- return result.data;
28
- }
29
-
30
- public clear() {
31
- for (let i = 0; i < localStorage.length; i++) {
32
- const key = localStorage.key(i);
33
- if (key && key.startsWith(this.keyPrefix)) {
34
- localStorage.removeItem(key);
35
- i--; // Decrement i since we've removed an item
36
- }
37
- }
38
- }
39
-
40
- private key(user: UserParams) {
41
- return `${this.keyPrefix}-${keccak256(toHex(user.jwt))}`;
42
- }
43
- }